I Am Trying To Run A Hello World Application Which I Downloaded From The Net. But I Am Getting An Error Saying That Driver Class Not Found Where I Am Specifying The Driver Name As Follows
'com.mysql.jdbc.driver'
Which Is Not Recognising Can Anyone Help In Running My First Hibernate Applciation.
Thanks In Advance:'(

Recommended Answers

All 4 Replies

Did you included the driver jar file in your class path ...?Secondly, which class of driver you are using Type2 or Type3 or type 4 ...? If you didn't specified then go to environemnt variable and in classpath variable add the path of your jar file.

Did you included the driver jar file in your class path ...?Secondly, which class of driver you are using Type2 or Type3 or type 4 ...? If you didn't specified then go to environemnt variable and in classpath variable add the path of your jar file.

I am using jdbcodbcdriver, thing is i am condused, since it is my first application using hibernate.i mean in my hibernate.cfg.xml file how to specify my database connection using datasource name if you help me with sample code that will be great i think because of that the session is not getting created in my HibernateUtil class

waiting for your reply

First thing it depends on your configuration, type of driver you are using and all .You can set your properties like this :

Scenerio #1 : Direct JDBC Connection:
If you wish to use a straight JDBC connection then you define the following properties in the hibernate.properties file:

[INDENT]hibernate.connection.driver_class= org.postgresql.Driver[/INDENT][INDENT]hibernate.connection.url=jdbc:postgresql://localhost/mydatabase[/INDENT][INDENT]hibernate.connection.username = myuser[/INDENT][INDENT]hibernate.connection.password=secrethibernate.c3p0.min_size=5[/INDENT][INDENT]hibernate.c3p0.max_size=20[/INDENT][INDENT]hibernate.c3p0.timeout=1800[/INDENT][INDENT]hibernate.c3p0.max_statements=50[/INDENT][INDENT]hibernate.dialect= net.sf.hibernate.dialect.PostgreSQLDialec[/INDENT]

Scenerio #2 : Datasource Connection Pool:
To use a connection pool from an external vendor specify the following properties in the hibernate.properties file:

[INDENT]hibernate.connection.datasource=java:/comp/env/jdbc/MyDB[/INDENT][INDENT]hibernate.transaction.factory_class=\net.sf.hibernate.transaction.JTATransactionFactory[/INDENT][INDENT]hibernate.transaction.manager_lookup_class=\net.sf.hibernate.transaction.JBossTransactionManagerLookup[/INDENT]

[INDENT]hibernate.dialect=\net.sf.hibernate.dialect.PostgreSQLDialect[/INDENT]

In scenario 2 define your JDBC resource in the Application Server (For ex : JBoss-Tomcat-Catalina container (server.xml) ) and reference it via the hibernate.properties file.

As i mentioned it depends on your configuration and requirment. If you have any other issues then post here. I'll help you out.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.