• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

hibernate.cfg.xml

 
Manojkr Jadhav
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:

<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">com.microsoft.jdbc.sqlserver.SQLServerDriver</property>
<property name="hibernate.connection.url">jdbc:microsoft:sqlserver://127.0.0.1:1433/abc</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="hibernate.hbm2ddl.auto">update</property>

<!-- Mapping files -->
<mapping resource="contact.hbm.xml"/>
</session-factory>
</hibernate-configuration>

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: com.microsoft.jdbc.sqlserver.SQLServerDriver
Exception in thread "main" java.lang.NullPointerException
at roseindia.tutorial.hibernate.FirstExample.main(FirstExample.java:42)


How to resolve
 
veeresh soni
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out the jar file for driver is having same driver .
 
Vijitha Kumara
Bartender
Posts: 3913
9
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
xsunil kumar
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

-Sunil
 
Lucene china
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
don't be against the wall you can do it with above instructions
 
Aby Krishna
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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: com.microsoft.jdbc.sqlserver.SQLServerDriver
Correct driver class string: com.microsoft.sqlserver.jdbc.SQLServerDriver
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic