wood burning stoves 2.0*
The moose likes Object Relational Mapping and the fly likes Hibernate JDBC connection problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate JDBC connection problem" Watch "Hibernate JDBC connection problem" New topic
Author

Hibernate JDBC connection problem

Nate deBrom
Greenhorn

Joined: May 22, 2004
Posts: 5
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?
Madhu Kumar Vatts
Ranch Hand

Joined: Apr 01, 2004
Posts: 74
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


Oracle Certified Enterprise Architect (Part 1);SUN Certified Programmer;SUN Certified Business Component Developer;SUN Certified Web Component Developer;
Oracle Certified WebServices Developer;Oracle Certified Java Persistence API Developer;Oracle Certified SQL Expert;IBM Certified XML Solution Developer
Nate deBrom
Greenhorn

Joined: May 22, 2004
Posts: 5
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?
Thanos Mavroidis
Greenhorn

Joined: Oct 20, 2004
Posts: 1
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.
Surya Suravarapu
Greenhorn

Joined: Oct 20, 2004
Posts: 10
Make sure that you have hibernate properties files in your classpath.

- SPS
[ October 20, 2004: Message edited by: Surya Suravarapu ]
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

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.


GenRocket - Experts at Building Test Data
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hibernate JDBC connection problem
 
Similar Threads
Hibernate and PostgreSQL
Trying to set up Connection Pooling using Glassfish
Hibernate Configuration ODBC SQL Server
Hibernate static SessionFactory
hibernate connection.