• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Problem with Hibernate and Oracle

 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've used Hibernate before with Derby, but I can't seem to get it working with Oracle. I'm using Oracle 9.2.0.1 and Hibernate 4.1.1 and my code is as simple as it can get:



I get the following when I run this code:



I've updated my JDBC drivers, searched for hours and I'm at a loss. Anybody see anything wrong with my code?
 
Ranch Hand
Posts: 344
Oracle Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I noticed you're using "default_schema" instead of "hibernate.default_schema", not sure if that would cause this issue. I think you also may need to specify a pool size for JDBC connections (hibernate.connection.pool_size).
 
Joe Ess
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, but I still get the same error:



 
Koen Aerts
Ranch Hand
Posts: 344
Oracle Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have never used Hibernate like this before; I normally use Hibernate's XML or properties config file. Did you try that approach too? Also, are all relevant jar files included on the java command line; i.e. Oracle driver (i.e. ojdbc14.jar) and Hibernate jars, etc.?
 
Joe Ess
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried using a hibernate.hbm.xml file with the same settings. I changed it to the programmatic configuration to post here, thinking one fewer file would make the code easier to read. The results were the same.
My classpath contains all the files in the Hibernate required directory as well as the current directory and the Oracle driver:
 
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try Changing setProperty("hibernate.default_schema", "ZZZZZ") to setProperty("hibernate.default_schema", "zzzzz") to lower case.

https://forum.hibernate.org/viewtopic.php?f=6&t=998260


 
Joe Ess
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, Piyush. I saw that post and tried it both ways. Same error. For the record, Oracle Enterprise Manager Console shows the schema name as all-caps (and I removed the "real" values from the code I posted and the code you quoted).
 
Koen Aerts
Ranch Hand
Posts: 344
Oracle Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Would the following approach work?
 
Piyush Mangal
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Joe Ess wrote:Thanks, Piyush. I saw that post and tried it both ways. Same error. For the record, Oracle Enterprise Manager Console shows the schema name as all-caps (and I removed the "real" values from the code I posted and the code you quoted).



Try removing default schema property altogether and see if you are able to get rid of this error. Regarding connection URL jdbc:oracle:thin:@localhost:1521:WWWWW.
Are you sure WWWWW is valid SID?

 
Joe Ess
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The code looks like this now:



I got the same error:

 
Koen Aerts
Ranch Hand
Posts: 344
Oracle Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Piyush Mangal wrote:

Joe Ess wrote:Thanks, Piyush. I saw that post and tried it both ways. Same error. For the record, Oracle Enterprise Manager Console shows the schema name as all-caps (and I removed the "real" values from the code I posted and the code you quoted).



Try removing default schema property altogether and see if you are able to get rid of this error. Regarding connection URL jdbc:oracle:thin:@localhost:1521:WWWWW.
Are you sure WWWWW is valid SID?


Did you try the following syntax:
 
Piyush Mangal
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please try following code.

 
Joe Ess
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Piyush Mangal wrote:
Try removing default schema property altogether and see if you are able to get rid of this error. Regarding connection URL jdbc:oracle:thin:@localhost:1521:WWWWW.
Are you sure WWWWW is valid SID?



I removed the schema property. Same error. "WWWWW" appears in the tnsnames.ora and that whole connection URL is a copy/paste from a functioning Plain Old JDBC application. I just gave it a try and it works fine:


 
Piyush Mangal
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Joe Ess wrote:

Piyush Mangal wrote:

I removed the schema property. Same error. "WWWWW" appears in the tnsnames.ora and that whole connection URL is a copy/paste from a functioning Plain Old JDBC application. I just gave it a try and it works fine:




Can you post the content of DBConnector ?

 
Piyush Mangal
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
PS if you look at the log, the application is trying to use cclinic

 
Joe Ess
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Piyush Mangal wrote:Please try following code.



Same error as before.
 
Koen Aerts
Ranch Hand
Posts: 344
Oracle Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well you can always download the Hibernate source code and see if you can find anything there: http://sourceforge.net/projects/hibernate/files/hibernate4/

The null pointer issue seems to originate from org.hibernate.engine.jdbc.internal.JdbcServicesImpl on the last line shown below:


So I suspect that "dialect" is a null object; not sure why. I thought it could have been related to something in ServiceRegistryImplementor, which is something new in Hibernate 4: https://community.jboss.org/wiki/HibernateCoreMigrationGuide40
 
Ranch Hand
Posts: 541
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
- Try downloading the hibernate jar again, may be this one is corrupted?
- Try different combinations of dialect and hibernate versions to separate the issue.

Not sure if order of property matters, I have dialect,url,usename,passwprd and driver class. I do not have default schema. and I have 10g dialect.

Good luck!
 
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Joe Ess wrote:I tried using a hibernate.hbm.xml file with the same settings...


You meant the cfg.xml file right? I also suggest first try with a sample form your distribution with xml config and see. If you already done so, did it work?
 
Greenhorn
Posts: 1
  • Likes 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To close the loop on this, I had to add the following property to hibernate.cfg.xml to get it to work for me:

<property name="hibernate.temp.use_jdbc_metadata_defaults">false</property>
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ben Fisher wrote:To close the loop on this, I had to add the following property to hibernate.cfg.xml to get it to work for me:

<property name="hibernate.temp.use_jdbc_metadata_defaults">false</property>



Thank you! I had the same problem, which the above resolved.
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ben Fisher wrote:To close the loop on this, I had to add the following property to hibernate.cfg.xml to get it to work for me:

<property name="hibernate.temp.use_jdbc_metadata_defaults">false</property>



Thanks Ben! This solved my problem too.

I was working fine on Win7/Oracle 10g DB, but when I moved my build over to SunOS using same 10g DB I was getting the error. Googling the first two lines of the exception brought me here.

Adding the new property didn't hurt my Win7 build either.

--Bob
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic