views:

2603

answers:

2

Hello friends,

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.

+2  A: 

It's most likely one of two cases:

  1. You are connecting as a user other than the owner of the table and can't resolve the name.
  2. 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';

dpbradley
+2  A: 

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
Justin