Solved

Servlet Hibernate - java.sql.SQLException: No suitable driver found for org.postgresql.Driver

Posted on 2010-11-27
8
1,181 Views
Last Modified: 2013-11-13
Hi,

I new at Hibernate and I wrote a littel test application in Ecplipse to test and learn how Hibernate works. This small program works well and Hibernate could find org.postgres.Driver and is reading and writing to the database correct.

Then when I try to test my code in a servlet it can't find the Postgres driver.

I get the following error:
2010-nov-26 07:16:35 org.hibernate.cfg.Configuration applyHibernateValidatorLegacyConstraintsOnDDL
INFO: Hibernate Validator not found: ignoring
2010-nov-26 07:16:35 org.hibernate.cfg.search.HibernateSearchEventListenerRegister enableHibernateSearch
INFO: Unable to find org.hibernate.search.event.FullTextIndexEventListener on the classpath. Hibernate Search is not enabled.
2010-nov-26 07:16:35 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Using Hibernate built-in connection pool (not for production use!)
2010-nov-26 07:16:35 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 20
2010-nov-26 07:16:35 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: autocommit mode: false
2010-nov-26 07:16:35 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: org.postgresql.Driver at URL: org.postgresql.Driver
2010-nov-26 07:16:35 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=postgres, password=****}
2010-nov-26 07:16:35 org.hibernate.cfg.SettingsFactory buildSettings
VARNING: Could not obtain connection to query metadata
java.sql.SQLException: No suitable driver found for org.postgresql.Driver
        at java.sql.DriverManager.getConnection(DriverManager.java:602)
        at java.sql.DriverManager.getConnection(DriverManager.java:154)
        at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:133)
        at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:114)
        at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2833)
        at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2829)
        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1840)
        at se.bostadsforsaljning.managers.HibernateManager.<init>(HibernateManager.java:62)
        at se.bostadsforsaljning.server.Server.processRequest(Server.java:103)
        at se.bostadsforsaljning.server.Server.doPost(Server.java:83)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
        at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:861)
        at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)
        at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1584)

The driver i using for Postgres i postgresql-8.4-701.jdbc4.jar.

How do I solve this issue?

0
Comment
Question by:freeOne
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
8 Comments
 
LVL 92

Expert Comment

by:objects
ID: 34221532
you need to add the driver jar to your container by adding the jat to tomcats lib directory
0
 

Author Comment

by:freeOne
ID: 34228889
I have put the jar file in:

...\apache-tomcat-6.0.28\lib

But, even if its there it is not working....
0
 

Author Comment

by:freeOne
ID: 34228918
The driver I'm using is postgresql-8.4-701.jdbc4.jar.

I have tried to put it in the above given folder and under the sites WEB_INF/lib

But nothinng works.

Any idée what i should do?
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 92

Expert Comment

by:objects
ID: 34234390
is the class it is looking for in that jar?
0
 

Author Comment

by:freeOne
ID: 34240573
Yes, it is there...

I have tried both and postgresql-8.4-701.jdbc4.jar and postgresql-9.0-801.jdbc3.jar

in the folders:
...\apache-tomcat-6.0.28\lib
...\WEB_INF/lib

and Hibernate can't find it anny were.
0
 
LVL 92

Accepted Solution

by:
objects earned 500 total points
ID: 34242948
whats your connection string?
0
 

Author Comment

by:freeOne
ID: 34245759
Thanks alot for your help.

It was the connection string that was wrong. When I changed it to the correct one it worked perfectly with all verions mentioned above.
0
 

Author Closing Comment

by:freeOne
ID: 34245761
Thanks a lot
0

Featured Post

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Introduction to Processes

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question