• 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:

Hibernate JDBC connection problem

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm new to hibernate, and i'm unclear about the error i'm recieving


i have my hibernate.properties set up properly(i can retrieve them from the Configuration object through a little routine i set up), and my JDBC drivers are in the correct path.
the error occurs at this line of code



i've read the hibernate documentation, and i'm reading 'Hibernate in Action', but i'm obviously missing something. can anyone give me a hint?
 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am working on hibernate and was able to make it working. I didnt get your problem clearly. If you could explain me I will help you

Madhu
 
Nate deBrom
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, thanks for your response.
The problem i'm having is with the following section of code


This is just a test that i'm running in order to learn Hibernate. Instead of using the 'hibernate.hbm.xml' file, i'm using the 'hibernate.properties' to set my parameters. When i run the test, i get the error that i specified in my orginal post. However, if i run the code by placing a java.sql.Connection object as a parameter of sessions.openSession, the code works.
My question is this: shouldn't the parameters of the 'hibernate.properties' be good enough to set up a connection to the database when i create a Configuration object?
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am new to Hibernate as well and I had the same error message. If you load your properties directly from your hibernate.properties file, your code fragment should work. So if your properties file is in the PROPS_DIR directory then something like:

Properties props = new Properties();
props.load(new FileInputStream("PROPS_DIR/hibernate.properties"));
Configuration cfg = new Configuration();
cfg.setProperties(props);

instead of:

Configuration cfg = new Configuration();
cfg.setProperties(System.getProperties());

should work. Other than that, I can only think that you are not passing all
hibernate properties to the system. Have you checked System.getProperties()
to see if all the Hibernate properties that you are passing to the JVM are there ?

hope this helps,

Thanos.
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Make sure that you have hibernate properties files in your classpath.

- SPS
[ October 20, 2004: Message edited by: Surya Suravarapu ]
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would recommend using the XML configuration option instead of the properties file. It not only keeps everything in 1 centralized location, but it keeps you from having lines like:

cfg.addResource("Cat.hbm.xml");

in your code.
 
reply
    Bookmark Topic Watch Topic
  • New Topic