File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Hibernate JDBC connection problem

Nate deBrom

Joined: May 22, 2004
Posts: 5
I'm new to hibernate, and i'm unclear about the error i'm recieving

i have my 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

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


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

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 '' 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 '' be good enough to set up a connection to the database when i create a Configuration object?
Thanos Mavroidis

Joined: Oct 20, 2004
Posts: 1

I am new to Hibernate as well and I had the same error message. If you load your properties directly from your 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/"));
Configuration cfg = new Configuration();

instead of:

Configuration cfg = new Configuration();

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,

Surya Suravarapu

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

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

Joined: Jul 11, 2001
Posts: 15302

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:


in your code.

GenRocket - Experts at Building Test Data
I agree. Here's the link:
subject: Hibernate JDBC connection problem
It's not a secret anymore!