Meaningless Drivel is fun!*
The moose likes Other Java Products and Servers and the fly likes GlassFish: Another Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Java Products and Servers
Bookmark "GlassFish: Another "No suitable driver found" exception (web application)" Watch "GlassFish: Another "No suitable driver found" exception (web application)" New topic
Author

GlassFish: Another "No suitable driver found" exception (web application)

Iván V. González
Greenhorn

Joined: Apr 06, 2010
Posts: 2
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]
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2500
    
    8

Can you ping the datapool from the GlassFish admin console.
This error (just as you found out when searching the JavaRanch) points out that a Driver that can handle this url is not loaded.

Can you show us how the datapool that you use in your <sql:query> JSTL tag is configured in GlassFish?


OCUP UML fundamental and ITIL foundation
youtube channel
Iván V. González
Greenhorn

Joined: Apr 06, 2010
Posts: 2
I don't fully understand your question, e.g. I don't neither know how to ping the datapool in GlassFish nor if I'm using it. I'm a complete newbie using GlassFish; I'm just using it through NetBeans. That's the way I'm connecting:

I'm not using (at least I think so) datapools managed by the application server, I'm keeping it real simple: I just define the default database connection at "web.xml" this way:

An then use it with simple queries like this:


I've also tried simplifying it to just this:


As of my knowledge I think this is the simplest and easiest way to do it, and as my application doesn't need much performance I preferred this to using more complex systems. I'm not sure if this is what you asked for...

Thank you for your answer.
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2500
    
    8

I will move this thread to our Other Java Products and Servers forum.
I think the issue has more to do with how the data pool is set up, than with jdbc.
I have also changed the title, so that people see that it is related to GlassFish.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: GlassFish: Another "No suitable driver found" exception (web application)