oracle 11g hibernate problem - oracle

I am changing my database from PostgreSQL to Oracle 11g. I am using hibernate 3.0 with Java and Struts.
Everything is working fine with PostgreSQL.
I have changed following in hibernate.cfg.xml file.
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.password">mypassword</property>
<property name="hibernate.connection.url">jdbc:Oracle:thin:#192.168.1.1:1521/mydb</property>
<property name="hibernate.connection.username">my_user</property>
<property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
Everything else is same as that was in Postgresql.
I am using ojdbc5.jar
Now when I run my page it gives me following error.
ORA-00903: invalid table name
Can any one help me regarding the matter?
Thanks.

dpbradley is probably correct, however, I just ran into the following problem with 11g and hibernate:
- oracle 11g will let you define a table with a name larger than 30 characters
- however, you can't actually refer to that table in a SQL statement because its name is too long.
Hibernate auto generated DDL does not seem care or warn when it generates the DDL

It's most likely one of two cases:
You are connecting as a user other than the owner of the table and can't resolve the name.
There is a problem with case sensitivity in either the reference to the table name in the code or its actual name.
If you are not the owner of the table (but have grants to access it!), you'll need to either have an Oracle synonym that translates a reference to MYTABLE into THE_ACTUAL_OWNER.MYTABLE, or reference the schema qualifier directly in your code.
The second case is less likely, but sometimes table creation scripts will create objects in oracle with double quotes around the object name, which will allow creation of mixed-case identifier - CREATE TABLE "myTable" will create the mixed case identifier which then must be referenced by the mixed-case string.
To provide us with further info, connect with some sort of ad-hoc SQL tool as the same user as your application and post the results of:
select owner, table_name from all_tables where table_name = 'theNameOfTheTableOfinterest';

Related

The problem of openGauss database connection schema

we encountered a problem when migrating the database from oracle to guassdb. It is a compatible version with postgresdb, which uses schema,
For example, select * from table1
Now because gauss uses schema, our table is in a01
The query becomes select * from a01.table1, which causes all the codes to be changed during the migration. The schema is added to the front of each table name, which is too big. Is there a better solution, such as adding schema to the url connection, because we only use one schema for each project
You can configure the user's search_path in the openGauss database. This parameter can also be configured through the url parameter in the jdbc.
for example: jdbc:postgresql://localhost:5432/mydatabase?currentSchema=a1

Using oracle seq generator in Informatica Mapping [duplicate]

I use SQL developer and i made a connection to my database with the system user, after I created a user and made a another connection with that user with all needed privileges.
But when I try to proceed following I get the SQL Error
ORA-00942 table or view does not exist.:
INSERT INTO customer (c_id,name,surname) VALUES ('1','Micheal','Jackson')
Because this post is the top one found on stackoverflow when searching for "ORA-00942: table or view does not exist insert", I want to mention another possible cause of this error (at least in Oracle 12c): a table uses a sequence to set a default value and the user executing the insert query does not have select privilege on the sequence. This was my problem and it took me an unnecessarily long time to figure it out.
To reproduce the problem, execute the following SQL as user1:
create sequence seq_customer_id;
create table customer (
c_id number(10) default seq_customer_id.nextval primary key,
name varchar(100) not null,
surname varchar(100) not null
);
grant select, insert, update, delete on customer to user2;
Then, execute this insert statement as user2:
insert into user1.customer (name,surname) values ('michael','jackson');
The result will be "ORA-00942: table or view does not exist" even though user2 does have insert and select privileges on user1.customer table and is correctly prefixing the table with the schema owner name. To avoid the problem, you must grant select privilege on the sequence:
grant select on seq_customer_id to user2;
Either the user doesn't have privileges needed to see the table, the table doesn't exist or you are running the query in the wrong schema
Does the table exist?
select owner,
object_name
from dba_objects
where object_name = any ('CUSTOMER','customer');
What privileges did you grant?
grant select, insert on customer to user;
Are you running the query against the owner from the first query?
Case sensitive Tables (table names created with double-quotes) can throw this same error as well. See this answer for more information.
Simply wrap the table in double quotes:
INSERT INTO "customer" (c_id,name,surname) VALUES ('1','Micheal','Jackson')
You cannot directly access the table with the name 'customer'. Either it should be 'user1.customer' or create a synonym 'customer' for user2 pointing to 'user1.customer'. hope this helps..
Here is an answer: http://www.dba-oracle.com/concepts/synonyms.htm
An Oracle synonym basically allows you to create a pointer to an object that exists somewhere else. You need Oracle synonyms because when you are logged into Oracle, it looks for all objects you are querying in your schema (account). If they are not there, it will give you an error telling you that they do not exist.
I am using Oracle Database and i had same problem. Eventually i found ORACLE DB is converting all the metadata (table/sp/view/trigger) in upper case.
And i was trying how i wrote table name (myTempTable) in sql whereas it expect how it store table name in databsae (MYTEMPTABLE). Also same applicable on column name.
It is quite common problem with developer whoever used sql and now jumped into ORACLE DB.
in my case when i used asp.net core app i had a mistake in my sql query. If your database contains many schemas, you have to write schema_name before table_name, like:
Select * from SCHEMA_NAME.TABLE_NAME...
i hope it will helpful.

Liquibase-generated SQL gives ORA-01735 error

I am running the following changeset on an Oracle 12 database (the latest official docker image). When the changeset is executed, I get a SQL error:
Error: ORA-01735: invalid ALTER TABLE option
[Failed SQL: ALTER TABLE TEST.LANGUAGE ADD CONSTRAINT SYS_C0010528 PRIMARY KEY (ID) USING INDEX TEST.SYS_C0010528]
I generated the changeset from an existing Oracle database schema using Liquibase tools, with minor alterations.
Does liquibase not support Oracle 12?
How do I configure liquibase to generate Oracle 12-compatible SQL?
Is this a settings issue, or a bug in Liquibase?
Details:
It looks like Oracle doesn't accept the qualifier for the index name in the USING INDEX statement. The following revised SQL seems to work as intended:
ALTER TABLE TEST.LANGUAGE ADD CONSTRAINT SYS_C0010528 PRIMARY KEY (ID) USING INDEX SYS_C0010528
Here is the changeset definition:
<changeSet author="rmorrise (generated)" id="1507039841670-7">
<preConditions onFail="MARK_RAN">
<not>
<primaryKeyExists tableName="LANGUAGE"/>
</not>
</preConditions>
<createIndex indexName="SYS_C0010528" tableName="LANGUAGE" unique="true">
<column name="ID"/>
</createIndex>
<addPrimaryKey columnNames="ID" constraintName="SYS_C0010528" forIndexName="SYS_C0010528" tableName="LANGUAGE"/>
</changeSet>
Update:
I fixed the <addPrimaryKey> entries by replacing them with <sql> tags, but I got the same error on <addUniqueConstraint> with forIndexName.
Here is the generated SQL to create the index. It appears to be created in the same schema.
CREATE UNIQUE INDEX TEST.UK46FCA532E38E4F92860631AA28CB ON TEST.MESSAGE_ROLE(TEMPLATE_ID, LABEL);
ALTER TABLE TEST.MESSAGE_ROLE ADD CONSTRAINT UK46FCA532E38E4F92860631AA28CB UNIQUE (TEMPLATE_ID, LABEL) USING INDEX TEST.UK46FCA532E38E4F92860631AA28CB;
To answer Alex's question about the use of system object names: The schema was originally generated by hbm2ddl and migrated to liquibase using generateChangelog.
A query to dba_objects confirms that the OWNER is TEST.
I had a similar problem and as I was reading this topic I see that we both named our schema "TEST".
I changed the schema's name and it worked immediatly.

informatica execute sql in sql transformation

Background: I am really new. Informatica Developer for PowerCenter Express Version: 9.6.1 HotFix 2
I want to execute a t-sql statement as one step in a work flow:
truncate table dbo.stage_customer
I tried create a mapping, add a sql transformation on it. Input above query in sql query window. I added the mapping to a workflow of just start, the mapping, and the end. When I validate the flow I got this error:
The group [Input] in transformation xxx must have at least one port
I have no idea what ports are needed since this (the truncate statement) basically doesn't need input or output.
Use your query " truncate table dbo.stage_customer" in Pre-SQL command
As Aswin suggested use the built in option in the session property.
But in the production environments user may not have truncate table access for the table in a database. In this case, informatica workflow will fail if you check the truncate target table option. It is good to have a stored procedure to truncate the target table and use that stored procedure in informatica mapping to avoid workflow failures in case of user having no truncate access to the database.
if you would like to truncate a target table before loading why don't you use the in-built option present in session properties?
goto workflow manager-> open session->mapping tab->click on target table listed left side->choose the property "Truncate table option" just enable it
to answer you question, I think you have to connect at least one input and output port into SQL transformation (because it is not unconnected). Just create dummy ports and try again
try this article - click here

Schema name prefix issue in SQL query

I have WMADMIN schema. This schema is configured as connection credential in websphere datasource.
I have table in other schema/user OCS_JOBS. But the problem is my application looking for the table in WMADMIN schema.
It looks i need to prefix schemaname OCS_JOBS in SQL query to run them.
Is there any other way to run the SQL query the table which is in other user/schema without prefixing the other schema name
You can create a SYNONYM see it here: http://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_7001.htm

Resources