Hello everybody:
I have a typical (as I've seen it so many times in this and other forums) "java.sql.SQLException: No suitable driver found for jdbc:postgresql:mydb" exception in my JSP web application.
Here it is the complete trace:
The problem is generated at a simple <sql:query> JSTL tag: I'm not using connection pooling or any kind of sophisticated code.
I've searched through the net many times about it and found many answers to it, and I've also seen the Ranch FAQ on the topic; so I know that this error usually means that the URL is wrong, or that the loaded driver is not the right one. But I still don't know whats the problem in my case, as I've yet connected succesfully to the database, and used the same driver and JDBC URL previously.
This application was working fine previously (it's already in production) but this problem is happening since I've changed my development environment from Tomcat to GlassFish (I'm using NetBeans 6.8 now, and using it instead of Tomcat seems o.k. to me). The application was working fine then and when I opened it with the new IDE version to do some enhancements, it throws the mentioned runtime error.
Some things I've checked (some of them thanks to other posts in this forum):
.- I have access permissions, in fact I can access that database from the NetBeans DB query interface and from other application (not web application) using the same JDBC driver.
.- I've tried different JDBC URL sintaxes (with server's IP number, with server's DNS name, with "localhost" and "127.0.0.1", without server's specification, with and without port number [which is the default one], specifying the user and password into the URL or apart).
.- I've tried using the <sql:setDataSource> tag or the "javax.servlet.jsp.jstl.sql.dataSource" context property.
.- I've checked the actual driver class ("postgresql-8.3-603.jdbc3.jar") is included in the deployed "WEB-INF/lib" folder (Anyway, if the driver wasn't found I suppose it would throw the ClassNotFound exception instead...).
.- I've tried using different driver classes (version numbers and types [jdbc3, jdbc4]) as I'm never sure which one is the best. Finally I stuck with the one known to work in my environment (remember this application is already working in another computer).
.- I've tried copying the driver class file directly into "glassfish/lib" (although it seems to me it does not make sense as the .war file generated should be autosufficient).
Nothing worked.
Don't know what else to check!...
Do I have to use a different URL sintax for the JDBC in Glassfish? Is there really a difference between using Tomcat or Glassfish? Maybe Glassfish is completely unrelated with this problem...
I'm pretty sure this is going to have a really stupid fix but, you know, when you spend many time looking for something, you can't see it in front of your very eyes...
Thank you in advance.
[jc: added GlassFish to the subject line]