Re: Fwd: JDBC connection - Please help
Deepak, This '' and null error means that the Tomcat is not finding the JDBC JNDI resource. This is how to fix this on Tomcat 5.5: Make sure that you have a Resource element properly configured in your context.xml that is in $CATALINA_HOME/conf/ directory. Resource name=jdbc/TestDB auth=Container type=javax.sql.DataSource maxActive=100 maxIdle=30 maxWait=1 username=someuser password=somepassword driverClassName=your driver url=proper url for your db's jdbc conventions/ /Context Make sure it is available to your web app, by setting the references in your web.xml. resource-ref descriptionDB Connection/description res-ref-namejdbc/TestDB/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref Thank you, Edmon http://blogs.ittoolbox.com/eai/software deepak suldhal wrote: When I write a simple java class to get the driver and connection it works fine. I am able to retrive row and print them. But I am not able to get the same on Tomcat server. Note: forwarded message attached. Do you Yahoo!? The all-new My Yahoo! http://my.yahoo.com What will yours do? Subject: JDBC connection - Please help From: deepak suldhal [EMAIL PROTECTED] Date: Sun, 20 Feb 2005 22:22:48 -0800 (PST) To: tomcat users tomcat-user@jakarta.apache.org To: tomcat users tomcat-user@jakarta.apache.org Please help me make my first JDBC connection My web.xml web-app xmlns=http://java.sun.com/xml/ns/j2ee; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xsi:schemaLocation=http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd; version=2.4 descriptionMySQL Test App/description resource-ref descriptionDB Connection/description res-ref-namejdbc/TestDB/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref /web-app --- In server.xml I have the following context ( trying to connect to Sybase database) Context path=/DBTest docBase=DBTest debug=5 reloadable=true crossContext=true Resource name=jdbc/TestDB auth=Container type=javax.sql.DataSource maxActive=100 maxIdle=30 maxWait=1 username=javauser password=javadude driverClassName=com.sybase.jdbc2.jdbc.SybDriver url=jdbc:sybase:Tds:re2unx188:2025/ /Context --- I have copied the JDCB drive Jar under commons/lib I have a test.jsp as follows --- %@ taglib uri=http://java.sun.com/jsp/jstl/sql; prefix=sql % %@ taglib uri=http://java.sun.com/jsp/jstl/core; prefix=c % sql:query var=rs dataSource=jdbc/TestDB select id, foo, bar from testdata /sql:query html head titleDB Test/title /head body h2Results/h2 c:forEach var=row items=${rs.rows} Foo ${row.foo}br/ Bar ${row.bar}br/ /c:forEach /body /html --- My directory structue is as follows webapps/DBTest/WEB-INF/web.mxl /DBTest/test.jsp --- And when I try the url http://localhost:8080/DBTest/test.jsp I am getting the following errors description The server encountered an internal error () that prevented it from fulfilling this request. exception javax.servlet.ServletException: Unable to get connection, DataSource invalid: org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null' org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825) org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758) org.apache.jsp.test_jsp._jspService(test_jsp.java:82) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) root cause javax.servlet.jsp.JspException: Unable to get connection, DataSource invalid: org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null' org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.getConnection(Unknown Source)
Fwd: JDBC connection - Please help
When I write a simple java class to get the driver and connection it works fine. I am able to retrive row and print them. But I am not able to get the same on Tomcat server. Note: forwarded message attached. Do you Yahoo!? The all-new My Yahoo! What will yours do?---BeginMessage--- Please help me make my first JDBC connection My web.xml web-app xmlns=http://java.sun.com/xml/ns/j2ee; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xsi:schemaLocation=http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd; version=2.4 descriptionMySQL Test App/description resource-ref descriptionDB Connection/description res-ref-namejdbc/TestDB/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref /web-app --- In server.xml I have the following context ( trying to connect to Sybase database) Context path=/DBTest docBase=DBTest debug=5 reloadable=true crossContext=true Resource name=jdbc/TestDB auth=Container type=javax.sql.DataSource maxActive=100 maxIdle=30 maxWait=1 username=javauser password=javadude driverClassName=com.sybase.jdbc2.jdbc.SybDriver url=jdbc:sybase:Tds:re2unx188:2025/ /Context --- I have copied the JDCB drive Jar under commons/lib I have a test.jsp as follows --- %@ taglib uri=http://java.sun.com/jsp/jstl/sql; prefix=sql % %@ taglib uri=http://java.sun.com/jsp/jstl/core; prefix=c % sql:query var=rs dataSource=jdbc/TestDB select id, foo, bar from testdata /sql:query html head titleDB Test/title /head body h2Results/h2 c:forEach var=row items=${rs.rows} Foo ${row.foo}br/ Bar ${row.bar}br/ /c:forEach /body /html --- My directory structue is as follows webapps/DBTest/WEB-INF/web.mxl /DBTest/test.jsp --- And when I try the url http://localhost:8080/DBTest/test.jsp I am getting the following errors description The server encountered an internal error () that prevented it from fulfilling this request. exception javax.servlet.ServletException: Unable to get connection, DataSource invalid: org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null' org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825) org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758) org.apache.jsp.test_jsp._jspService(test_jsp.java:82) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) root cause javax.servlet.jsp.JspException: Unable to get connection, DataSource invalid: org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null' org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.getConnection(Unknown Source) org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.doStartTag(Unknown Source) org.apache.jsp.test_jsp._jspx_meth_sql_query_0(test_jsp.java:101) org.apache.jsp.test_jsp._jspService(test_jsp.java:58) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236) javax.servlet.http.HttpServlet.service(HttpServlet.java:802 --- My console server display is as follows eb 20, 2005 10:31:08 PM org.apache.coyote.http11.Http11Protocol init INFO: Initializing Coyote HTTP/1.1 on http-8080 Feb 20, 2005 10:31:08 PM org.apache.catalina.startup.Catalina load INFO: Initialization processed in 1422 ms Feb 20, 2005 10:31:09 PM org.apache.catalina.core.StandardService start INFO: Starting service Catalina Feb