RE: problem with SQL tags
Hi John, My $.02. Although I'm not using MySQL, my experience with Tomcat 4.1.12 has been that I must place the JDBC Driver classes in the Tomcat common/lib directory. Although this is somewhat in contrast to the JSTL and other JARs, I found that including the JDBC driver classes in WEB-INF/lib not only caused the error you described, it did so even when I had the JARs in both locations. So, you might want to try including the classes ONLY in common/lib. Of course, once you get the JAR issue resolved, setting up a JNDI DataSource (with a pooled connection) is even better. Best of luck, Buck Bell -Original Message- From: John C Cartwright [mailto:[EMAIL PROTECTED]] Sent: Monday, November 18, 2002 11:32 AM To: Tag Libraries Users List Subject: Re: problem with SQL tags Thank you for your reply, Hans. The JDBC driver classes are in the webapps WEB-INF/lib directory and I was assuming that they are being found because a non-JSTL JSP page with a scriptlet block containing: Connection con; try { Class.forName(org.gjt.mm.mysql.Driver); con = DriverManager.getConnection(jdbc:mysql://myhost.noaa.gov:3306/testdb,test user,testpass); } catch (Exception e) { throw (new ServletException(Error loading Driver: +e.getMessage())); } seems to work fine. Does JSTL look for the Driver classes in a location other than the scriplet-based connection code? Thanks again! -- john Hans Bergsten wrote: John C Cartwright wrote: Hello All, I am hoping that someone can help me to get going with the SQL tags. I'm trying to connect to a mysql database using tomcat4.1.12 and version 1.0.2 of the library. Here's my JSP: %@ taglib prefix=sql uri=http://java.sun.com/jstl/sql; % %@ taglib prefix=c uri=http://java.sun.com/jstl/core; % HTML HEAD /HEAD BODY sql:setDataSource var=monitorDS url=jdbc:mysql://myhost.noaa.gov:3306/testdb driver=org.gjt.mm.mysql.Driver user=testuser password=testpass / /BODY /HTML I'm getting a: org.apache.jasper.JasperException: Unable to get connection, DataSource invalid: No suitable driver This is because the JDBC driver classes are not found by the web container. Make sure you have installed them in the WEB-INF/lib directory of the application. [...] Hans -- = John Cartwright Associate Scientist Geospatial Data Services Group CIRES, National Geophysical Data Center/NOAA (303) 497-6284 [EMAIL PROTECTED] = -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: problem with SQL tags
John C Cartwright wrote: Thank you for your reply, Hans. The JDBC driver classes are in the webapps WEB-INF/lib directory and I was assuming that they are being found because a non-JSTL JSP page with a scriptlet block containing: Connection con; try { Class.forName(org.gjt.mm.mysql.Driver); con = DriverManager.getConnection(jdbc:mysql://myhost.noaa.gov:3306/testdb,testuser,testpass); } catch (Exception e) { throw (new ServletException(Error loading Driver: +e.getMessage())); } seems to work fine. Does JSTL look for the Driver classes in a location other than the scriplet-based connection code? JSTL uses the standard Java API to look up the driver classes, which means it finds any class that is in the web apps classpath. It's the same no matter what type of code you use in the JSP page. If the class files really are in WEB-INF/lib, the only thing I can suggest is making sure that the JDBC URL is syntactically correct. If you still can't get it to work, it may be a bug in the JSTL implementation. Are you sure you use the JSTL implementation from Apache Taglibs? Note that Resin bundles it's own implementation. Hans Hans Bergsten wrote: John C Cartwright wrote: Hello All, I am hoping that someone can help me to get going with the SQL tags. I'm trying to connect to a mysql database using tomcat4.1.12 and version 1.0.2 of the library. Here's my JSP: %@ taglib prefix=sql uri=http://java.sun.com/jstl/sql; % %@ taglib prefix=c uri=http://java.sun.com/jstl/core; % HTML HEAD /HEAD BODY sql:setDataSource var=monitorDS url=jdbc:mysql://myhost.noaa.gov:3306/testdb driver=org.gjt.mm.mysql.Driver user=testuser password=testpass / /BODY /HTML I'm getting a: org.apache.jasper.JasperException: Unable to get connection, DataSource invalid: No suitable driver This is because the JDBC driver classes are not found by the web container. Make sure you have installed them in the WEB-INF/lib directory of the application. [...] Hans -- Hans Bergsten[EMAIL PROTECTED] Gefion Software http://www.gefionsoftware.com/ Author of O'Reilly's JavaServer Pages, covering JSP 1.2 and JSTL 1.0 Details athttp://TheJSPBook.com/ -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: problem with SQL tags
Bell, Buck (c) wrote: Hi John, My $.02. Although I'm not using MySQL, my experience with Tomcat 4.1.12 has been that I must place the JDBC Driver classes in the Tomcat common/lib directory. Although this is somewhat in contrast to the JSTL and other JARs, I found that including the JDBC driver classes in WEB-INF/lib not only caused the error you described, it did so even when I had the JARs in both locations. So, you might want to try including the classes ONLY in common/lib. Of course, once you get the JAR issue resolved, setting up a JNDI DataSource (with a pooled connection) is even better. You need to place them in common/lib only if you use JNDI (because the JNDI machinery is relying on other class loaders than the ones used for regular web app resources). Without JNDI, they should be found in WEB-INF/lib. I agree that using JNDI is a good idea, but what John is trying should work without it. Hans -Original Message- From: John C Cartwright [mailto:[EMAIL PROTECTED]] Sent: Monday, November 18, 2002 11:32 AM To: Tag Libraries Users List Subject: Re: problem with SQL tags Thank you for your reply, Hans. The JDBC driver classes are in the webapps WEB-INF/lib directory and I was assuming that they are being found because a non-JSTL JSP page with a scriptlet block containing: Connection con; try { Class.forName(org.gjt.mm.mysql.Driver); con = DriverManager.getConnection(jdbc:mysql://myhost.noaa.gov:3306/testdb,test user,testpass); } catch (Exception e) { throw (new ServletException(Error loading Driver: +e.getMessage())); } seems to work fine. Does JSTL look for the Driver classes in a location other than the scriplet-based connection code? Thanks again! -- john Hans Bergsten wrote: John C Cartwright wrote: Hello All, I am hoping that someone can help me to get going with the SQL tags. I'm trying to connect to a mysql database using tomcat4.1.12 and version 1.0.2 of the library. Here's my JSP: %@ taglib prefix=sql uri=http://java.sun.com/jstl/sql; % %@ taglib prefix=c uri=http://java.sun.com/jstl/core; % HTML HEAD /HEAD BODY sql:setDataSource var=monitorDS url=jdbc:mysql://myhost.noaa.gov:3306/testdb driver=org.gjt.mm.mysql.Driver user=testuser password=testpass / /BODY /HTML I'm getting a: org.apache.jasper.JasperException: Unable to get connection, DataSource invalid: No suitable driver This is because the JDBC driver classes are not found by the web container. Make sure you have installed them in the WEB-INF/lib directory of the application. [...] Hans -- Hans Bergsten[EMAIL PROTECTED] Gefion Software http://www.gefionsoftware.com/ Author of O'Reilly's JavaServer Pages, covering JSP 1.2 and JSTL 1.0 Details athttp://TheJSPBook.com/ -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: problem with SQL tags
Thanks to Buck and Hans for your reponses. Unfortunately, I'm still having the same problem. I tried: 1) moving the mysql driver JAR file to $TOMCAT/common/lib as Buck suggested 2) unpacking the JAR file into $WEBAPP/WEB-INF/classes 3) getting the latest mysql driver from mysql.com Still same results, a scriptlet-based connection works, the JSTL doesn't. I've tried both the 1.0.2 version of the JSTL tags as well as the nightly build from last Friday. Here again is the corresponding connection code. There's no difference that I can see between the driver class name or database URL. Any further suggestions? Thanks for your help! -- john Hans Bergsten wrote: Bell, Buck (c) wrote: Hi John, My $.02. Although I'm not using MySQL, my experience with Tomcat 4.1.12 has been that I must place the JDBC Driver classes in the Tomcat common/lib directory. Although this is somewhat in contrast to the JSTL and other JARs, I found that including the JDBC driver classes in WEB-INF/lib not only caused the error you described, it did so even when I had the JARs in both locations. So, you might want to try including the classes ONLY in common/lib. Of course, once you get the JAR issue resolved, setting up a JNDI DataSource (with a pooled connection) is even better. You need to place them in common/lib only if you use JNDI (because the JNDI machinery is relying on other class loaders than the ones used for regular web app resources). Without JNDI, they should be found in WEB-INF/lib. I agree that using JNDI is a good idea, but what John is trying should work without it. Hans -Original Message- From: John C Cartwright [mailto:[EMAIL PROTECTED]] Sent: Monday, November 18, 2002 11:32 AM To: Tag Libraries Users List Subject: Re: problem with SQL tags Thank you for your reply, Hans. The JDBC driver classes are in the webapps WEB-INF/lib directory and I was assuming that they are being found because a non-JSTL JSP page with a scriptlet block containing: Connection con; try { Class.forName(org.gjt.mm.mysql.Driver); con = DriverManager.getConnection(jdbc:mysql://myhost.noaa.gov:3306/testdb,test user,testpass); } catch (Exception e) { throw (new ServletException(Error loading Driver: +e.getMessage())); } seems to work fine. Does JSTL look for the Driver classes in a location other than the scriplet-based connection code? Thanks again! -- john Hans Bergsten wrote: John C Cartwright wrote: Hello All, I am hoping that someone can help me to get going with the SQL tags. I'm trying to connect to a mysql database using tomcat4.1.12 and version 1.0.2 of the library. Here's my JSP: %@ taglib prefix=sql uri=http://java.sun.com/jstl/sql; % %@ taglib prefix=c uri=http://java.sun.com/jstl/core; % HTML HEAD /HEAD BODY sql:setDataSource var=monitorDS url=jdbc:mysql://myhost.noaa.gov:3306/testdb driver=org.gjt.mm.mysql.Driver user=testuser password=testpass / /BODY /HTML I'm getting a: org.apache.jasper.JasperException: Unable to get connection, DataSource invalid: No suitable driver This is because the JDBC driver classes are not found by the web container. Make sure you have installed them in the WEB-INF/lib directory of the application. [...] Hans -- = John Cartwright Associate Scientist Geospatial Data Services Group CIRES, National Geophysical Data Center/NOAA (303) 497-6284 [EMAIL PROTECTED] = -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: problem with SQL tags
John, Humor me -- remove var=monitorDS from your sql:setDataSource tag, and try again. Thanks, Buck -Original Message- From: John C Cartwright [mailto:[EMAIL PROTECTED]] Sent: Monday, November 18, 2002 2:13 PM To: Tag Libraries Users List Subject: Re: problem with SQL tags Thanks to Buck and Hans for your reponses. Unfortunately, I'm still having the same problem. I tried: 1) moving the mysql driver JAR file to $TOMCAT/common/lib as Buck suggested 2) unpacking the JAR file into $WEBAPP/WEB-INF/classes 3) getting the latest mysql driver from mysql.com Still same results, a scriptlet-based connection works, the JSTL doesn't. I've tried both the 1.0.2 version of the JSTL tags as well as the nightly build from last Friday. Here again is the corresponding connection code. There's no difference that I can see between the driver class name or database URL. Any further suggestions? Thanks for your help! -- john Hans Bergsten wrote: Bell, Buck (c) wrote: Hi John, My $.02. Although I'm not using MySQL, my experience with Tomcat 4.1.12 has been that I must place the JDBC Driver classes in the Tomcat common/lib directory. Although this is somewhat in contrast to the JSTL and other JARs, I found that including the JDBC driver classes in WEB-INF/lib not only caused the error you described, it did so even when I had the JARs in both locations. So, you might want to try including the classes ONLY in common/lib. Of course, once you get the JAR issue resolved, setting up a JNDI DataSource (with a pooled connection) is even better. You need to place them in common/lib only if you use JNDI (because the JNDI machinery is relying on other class loaders than the ones used for regular web app resources). Without JNDI, they should be found in WEB-INF/lib. I agree that using JNDI is a good idea, but what John is trying should work without it. Hans -Original Message- From: John C Cartwright [mailto:[EMAIL PROTECTED]] Sent: Monday, November 18, 2002 11:32 AM To: Tag Libraries Users List Subject: Re: problem with SQL tags Thank you for your reply, Hans. The JDBC driver classes are in the webapps WEB-INF/lib directory and I was assuming that they are being found because a non-JSTL JSP page with a scriptlet block containing: Connection con; try { Class.forName(org.gjt.mm.mysql.Driver); con = DriverManager.getConnection(jdbc:mysql://myhost.noaa.gov:3306/testdb,test user,testpass); } catch (Exception e) { throw (new ServletException(Error loading Driver: +e.getMessage())); } seems to work fine. Does JSTL look for the Driver classes in a location other than the scriplet-based connection code? Thanks again! -- john Hans Bergsten wrote: John C Cartwright wrote: Hello All, I am hoping that someone can help me to get going with the SQL tags. I'm trying to connect to a mysql database using tomcat4.1.12 and version 1.0.2 of the library. Here's my JSP: %@ taglib prefix=sql uri=http://java.sun.com/jstl/sql; % %@ taglib prefix=c uri=http://java.sun.com/jstl/core; % HTML HEAD /HEAD BODY sql:setDataSource var=monitorDS url=jdbc:mysql://myhost.noaa.gov:3306/testdb driver=org.gjt.mm.mysql.Driver user=testuser password=testpass / /BODY /HTML I'm getting a: org.apache.jasper.JasperException: Unable to get connection, DataSource invalid: No suitable driver This is because the JDBC driver classes are not found by the web container. Make sure you have installed them in the WEB-INF/lib directory of the application. [...] Hans -- = John Cartwright Associate Scientist Geospatial Data Services Group CIRES, National Geophysical Data Center/NOAA (303) 497-6284 [EMAIL PROTECTED] = -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: problem with SQL tags
Hello again, I think that I found the problem. I had thought that the exception: org.apache.jasper.JasperException: Unable to get connection, DataSource invalid: No suitable driver was referring to the mysql driver classes not being loaded correctly. It seems that the problem was actually in the way that I was referring to the DataSource in the subsuquent sql:query tag. I was using: dataSource=$monitorDS but when I changed it to: datasource=${monitorDS} everything seems to work fine. I'm still not clear why exactly this is, but am delighted that it's working. Next task is to set up a JNDI datasource as Buck suggested. Thanks to all for the help! -- john = John Cartwright Associate Scientist Geospatial Data Services Group CIRES, National Geophysical Data Center/NOAA (303) 497-6284 [EMAIL PROTECTED] = -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: problem with SQL tags
John C Cartwright wrote: Thanks to Buck and Hans for your reponses. Unfortunately, I'm still having the same problem. I tried: 1) moving the mysql driver JAR file to $TOMCAT/common/lib as Buck suggested 2) unpacking the JAR file into $WEBAPP/WEB-INF/classes 3) getting the latest mysql driver from mysql.com Still same results, a scriptlet-based connection works, the JSTL doesn't. I've tried both the 1.0.2 version of the JSTL tags as well as the nightly build from last Friday. Here again is the corresponding connection code. There's no difference that I can see between the driver class name or database URL. Any further suggestions? Thanks for your help! Which web container are you using? If it's Resin, try to disable their native JSTL implementation (see their docs for how) to make sure you're really using the Apache Taglibs version. Other than that, I don't know what to suggest. All I can say is that I have similar examples running with Tomcat 4.0.4 (and 4.0.6 and 4.1.14). Hans Hans Bergsten wrote: Bell, Buck (c) wrote: Hi John, My $.02. Although I'm not using MySQL, my experience with Tomcat 4.1.12 has been that I must place the JDBC Driver classes in the Tomcat common/lib directory. Although this is somewhat in contrast to the JSTL and other JARs, I found that including the JDBC driver classes in WEB-INF/lib not only caused the error you described, it did so even when I had the JARs in both locations. So, you might want to try including the classes ONLY in common/lib. Of course, once you get the JAR issue resolved, setting up a JNDI DataSource (with a pooled connection) is even better. You need to place them in common/lib only if you use JNDI (because the JNDI machinery is relying on other class loaders than the ones used for regular web app resources). Without JNDI, they should be found in WEB-INF/lib. I agree that using JNDI is a good idea, but what John is trying should work without it. Hans -Original Message- From: John C Cartwright [mailto:[EMAIL PROTECTED]] Sent: Monday, November 18, 2002 11:32 AM To: Tag Libraries Users List Subject: Re: problem with SQL tags Thank you for your reply, Hans. The JDBC driver classes are in the webapps WEB-INF/lib directory and I was assuming that they are being found because a non-JSTL JSP page with a scriptlet block containing: Connection con; try { Class.forName(org.gjt.mm.mysql.Driver); con = DriverManager.getConnection(jdbc:mysql://myhost.noaa.gov:3306/testdb,test user,testpass); } catch (Exception e) { throw (new ServletException(Error loading Driver: +e.getMessage())); } seems to work fine. Does JSTL look for the Driver classes in a location other than the scriplet-based connection code? Thanks again! -- john Hans Bergsten wrote: John C Cartwright wrote: Hello All, I am hoping that someone can help me to get going with the SQL tags. I'm trying to connect to a mysql database using tomcat4.1.12 and version 1.0.2 of the library. Here's my JSP: %@ taglib prefix=sql uri=http://java.sun.com/jstl/sql; % %@ taglib prefix=c uri=http://java.sun.com/jstl/core; % HTML HEAD /HEAD BODY sql:setDataSource var=monitorDS url=jdbc:mysql://myhost.noaa.gov:3306/testdb driver=org.gjt.mm.mysql.Driver user=testuser password=testpass / /BODY /HTML I'm getting a: org.apache.jasper.JasperException: Unable to get connection, DataSource invalid: No suitable driver This is because the JDBC driver classes are not found by the web container. Make sure you have installed them in the WEB-INF/lib directory of the application. [...] Hans -- Hans Bergsten[EMAIL PROTECTED] Gefion Software http://www.gefionsoftware.com/ Author of O'Reilly's JavaServer Pages, covering JSP 1.2 and JSTL 1.0 Details athttp://TheJSPBook.com/ -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
problem with SQL tags
Hello All, I am hoping that someone can help me to get going with the SQL tags. I'm trying to connect to a mysql database using tomcat4.1.12 and version 1.0.2 of the library. Here's my JSP: %@ taglib prefix=sql uri=http://java.sun.com/jstl/sql; % %@ taglib prefix=c uri=http://java.sun.com/jstl/core; % HTML HEAD /HEAD BODY sql:setDataSource var=monitorDS url=jdbc:mysql://myhost.noaa.gov:3306/testdb driver=org.gjt.mm.mysql.Driver user=testuser password=testpass / /BODY /HTML I'm getting a: org.apache.jasper.JasperException: Unable to get connection, DataSource invalid: No suitable driver exception thrown even though a very similar JSP using standard JDBC connection methods (listed below) works fine. Connection con; try { Class.forName(org.gjt.mm.mysql.Driver); con = DriverManager.getConnection(jdbc:mysql://myhost.noaa.gov:3306/testdb,testuser,testpass); } catch (Exception e) { throw (new ServletException(Error loading Driver: +e.getMessage())); } Can someone help me? Thanks! -- john = John Cartwright Associate Scientist Geospatial Data Services Group CIRES, National Geophysical Data Center/NOAA (303) 497-6284 [EMAIL PROTECTED] = -- To unsubscribe, e-mail: mailto:taglibs-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:taglibs-user-help;jakarta.apache.org
Re: problem with SQL tags
John C Cartwright wrote: Hello All, I am hoping that someone can help me to get going with the SQL tags. I'm trying to connect to a mysql database using tomcat4.1.12 and version 1.0.2 of the library. Here's my JSP: %@ taglib prefix=sql uri=http://java.sun.com/jstl/sql; % %@ taglib prefix=c uri=http://java.sun.com/jstl/core; % HTML HEAD /HEAD BODY sql:setDataSource var=monitorDS url=jdbc:mysql://myhost.noaa.gov:3306/testdb driver=org.gjt.mm.mysql.Driver user=testuser password=testpass / /BODY /HTML I'm getting a: org.apache.jasper.JasperException: Unable to get connection, DataSource invalid: No suitable driver This is because the JDBC driver classes are not found by the web container. Make sure you have installed them in the WEB-INF/lib directory of the application. [...] Hans -- Hans Bergsten[EMAIL PROTECTED] Gefion Software http://www.gefionsoftware.com/ Author of O'Reilly's JavaServer Pages, covering JSP 1.2 and JSTL 1.0 Details athttp://TheJSPBook.com/ -- To unsubscribe, e-mail: mailto:taglibs-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:taglibs-user-help;jakarta.apache.org