freeOne
asked on
Servlet Hibernate - java.sql.SQLException: No suitable driver found for org.postgresql.Driver
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:
The driver i using for Postgres i postgresql-8.4-701.jdbc4.j ar.
How do I solve this issue?
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 applyHibernateValidatorLeg acyConstra intsOnDDL
INFO: Hibernate Validator not found: ignoring
2010-nov-26 07:16:35 org.hibernate.cfg.search.HibernateSe archEventL istenerReg ister enableHibernateSearch
INFO: Unable to find org.hibernate.search.event.FullTextI ndexEventL istener on the classpath. Hibernate Search is not enabled.
2010-nov-26 07:16:35 org.hibernate.connection.DriverManag erConnecti onProvider configure
INFO: Using Hibernate built-in connection pool (not for production use!)
2010-nov-26 07:16:35 org.hibernate.connection.DriverManag erConnecti onProvider configure
INFO: Hibernate connection pool size: 20
2010-nov-26 07:16:35 org.hibernate.connection.DriverManag erConnecti onProvider configure
INFO: autocommit mode: false
2010-nov-26 07:16:35 org.hibernate.connection.DriverManag erConnecti onProvider configure
INFO: using driver: org.postgresql.Driver at URL: org.postgresql.Driver
2010-nov-26 07:16:35 org.hibernate.connection.DriverManag erConnecti onProvider 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 (DriverMan ager.java: 602)
at java.sql.DriverManager.getConnection (DriverMan ager.java: 154)
at org.hibernate.connection.DriverManag erConnecti onProvider .getConnec tion(Drive rManagerCo nnectionPr ovider.jav a:133)
at org.hibernate.cfg.SettingsFactory.bu ildSetting s(Settings Factory.ja va:114)
at org.hibernate.cfg.Configuration.buil dSettingsI nternal(Co nfiguratio n.java:283 3)
at org.hibernate.cfg.Configuration.buil dSettings( Configurat ion.java:2 829)
at org.hibernate.cfg.Configuration.buil dSessionFa ctory(Conf iguration. java:1840)
at se.bostadsforsaljning.managers.Hiber nateManage r.<init>(H ibernateMa nager.java :62)
at se.bostadsforsaljning.server.Server. processReq uest(Serve r.java:103 )
at se.bostadsforsaljning.server.Server. doPost(Ser ver.java:8 3)
at javax.servlet.http.HttpServlet.servi ce(HttpSer vlet.java: 637)
at javax.servlet.http.HttpServlet.servi ce(HttpSer vlet.java: 717)
at org.apache.catalina.core.Application FilterChai n.internal DoFilter(A pplication FilterChai n.java:290 )
at org.apache.catalina.core.Application FilterChai n.doFilter (Applicati onFilterCh ain.java:2 06)
at org.apache.catalina.core.StandardWra pperValve. invoke(Sta ndardWrapp erValve.ja va:233)
at org.apache.catalina.core.StandardCon textValve. invoke(Sta ndardConte xtValve.ja va:191)
at org.apache.catalina.core.StandardHos tValve.inv oke(Standa rdHostValv e.java:127 )
at org.apache.catalina.valves.ErrorRepo rtValve.in voke(Error ReportValv e.java:102 )
at org.apache.catalina.core.StandardEng ineValve.i nvoke(Stan dardEngine Valve.java :109)
at org.apache.catalina.connector.Coyote Adapter.se rvice(Coyo teAdapter. java:298)
at org.apache.coyote.http11.Http11AprPr ocessor.pr ocess(Http 11AprProce ssor.java: 861)
at org.apache.coyote.http11.Http11AprPr otocol$Htt p11Connect ionHandler .process(H ttp11AprPr otocol.jav a:579)
at org.apache.tomcat.util.net.AprEndpoi nt$Worker. run(AprEnd point.java :1584)
The driver i using for Postgres i postgresql-8.4-701.jdbc4.j
How do I solve this issue?
you need to add the driver jar to your container by adding the jat to tomcats lib directory
ASKER
I have put the jar file in:
...\apache-tomcat-6.0.28\l ib
But, even if its there it is not working....
...\apache-tomcat-6.0.28\l
But, even if its there it is not working....
ASKER
The driver I'm using is postgresql-8.4-701.jdbc4.j ar.
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?
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?
is the class it is looking for in that jar?
ASKER
Yes, it is there...
I have tried both and postgresql-8.4-701.jdbc4.j ar and postgresql-9.0-801.jdbc3.j ar
in the folders:
...\apache-tomcat-6.0.28\l ib
...\WEB_INF/lib
and Hibernate can't find it anny were.
I have tried both and postgresql-8.4-701.jdbc4.j
in the folders:
...\apache-tomcat-6.0.28\l
...\WEB_INF/lib
and Hibernate can't find it anny were.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.
It was the connection string that was wrong. When I changed it to the correct one it worked perfectly with all verions mentioned above.
ASKER
Thanks a lot