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.cfg.xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "hibernate.cfg.xml" Watch "hibernate.cfg.xml" New topic


Manojkr Jadhav

Joined: Sep 05, 2009
Posts: 7
Hi i am using SQL server 2005 and hibernate.
i am not able to insert any data to the database via my application. i am able to do so using a normal java application.

My hibernate.cfg.xml:

<property name="hibernate.connection.driver_class"></property>
<property name="hibernate.connection.url">jdbc:microsoft:sqlserver://</property>
<property name="hibernate.connection.username">sa</property>
<property name="hibernate.connection.password">1234</property>
<property name="hibernate.connection.pool_size">10</property>
<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.SQLServerDialect</property>
<property name="">update</property>

<!-- Mapping files -->
<mapping resource="contact.hbm.xml"/>

I have some error.....

log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
JDBC Driver class not found:
Exception in thread "main" java.lang.NullPointerException
at roseindia.tutorial.hibernate.FirstExample.main(

How to resolve
veeresh soni

Joined: Dec 10, 2009
Posts: 12
Check out the jar file for driver is having same driver .
Vijitha Kumara

Joined: Mar 24, 2008
Posts: 3902

Manojkr Jadhav wrote:i am able to do so using a normal java application.

With the same information related to driver as in hibernate.cfg.xml?

[How to ask questions] [Twitter]
xsunil kumar
Ranch Hand

Joined: Dec 14, 2009
Posts: 137
Jadhav, You are able to insert data using normal java program, it means that required jar is in classpath. Can you post location of mssql jar and hiberante related jars.

This type of issue can come due to class loader Hireachy. If your hibernate related jars are in upper level of class loader hireachy than your mssql jar, then you will get class not found exception.

Are you getting this exception in you editor or in server. Try to put sql server related jars in server lib directory.

Lucene china

Joined: Dec 24, 2009
Posts: 4
don't be against the wall you can do it with above instructions

the sun is shunning,never give up.Go
Aby Krishna

Joined: Jul 10, 2010
Posts: 14
quite old..but one of the problem in the original poster's code is that the driver class string is incorrect.

OP's driver class string:
Correct driver class string:
I agree. Here's the link:
subject: hibernate.cfg.xml
It's not a secret anymore!