It seemes the compiler did not find your JDBC driver. You are using
JDBC:ODBC, then use"Class.forName("jdbc:odbc:JdbcOdbcDriver")". It is in the
java.sql package.
good luck
>From: JEANCHG <[EMAIL PROTECTED]>
>Reply-To: A mailing list about Java Server Pages specification and
> reference <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: JSP connects to DB
>Date: Tue, 7 Nov 2000 16:05:29 +0800
>
>I am new to this field, so I have some silly questions here.
>
>Can I call directly the method in JDBC classes in my jsp file to connect to
>my database, or it is necessary to write a connection bean to connect the
>DB.
>
>My JSP source code:
>
><%@ page language="java" %>
><%@ page import="java.lang.*" %>
><%@ page import="java.sql.*" %>
><%@ page contentType="text/html; charset=Big5" %>
><%Class.forName("Driver");%>
><%String url="jdbc:odbc:localhost";%>
><%Connection con=DriverManager.getConnection(url,"1234567890","1111");%>
><%Statement stmt =con.createStatement();%>
><%String test="select * from tbl_eDN";%>
><%ResultSet rs=stmt.executeQuery(test);%>
>
>But the error message on the web page is:
>
>Error: 500
>Location: /examples/jsp/jean/DBtest.jsp
>Internal Servlet Error:
>
>javax.servlet.ServletException: Unable to load class Driver
> at
>org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImp
>l.java:386)
> at
>jsp.jean._0002fjsp_0002fjean_0002fDBtest_0002ejspDBtest_jsp_0._jspService(_0
>002fjsp_0002fjean_0002fDBtest_0002ejspDBtest_jsp_0.java:111)
> at
>org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:126)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> at
>org.apache.jasper.runtime.JspServlet$JspServletWrapper.service(JspServlet.ja
>va:174)
> at
>org.apache.jasper.runtime.JspServlet.serviceJspFile(JspServlet.java:261)
> at
>org.apache.jasper.runtime.JspServlet.service(JspServlet.java:369)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> at
>org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:503)
> at
>org.apache.tomcat.core.ContextManager.service(ContextManager.java:559)
> at
>org.apache.tomcat.service.connector.Ajp12ConnectionHandler.processConnection
>(Ajp12ConnectionHandler.java:156)
> at
>org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoint.java:338
>)
> at java.lang.Thread.run(Thread.java:484)
>
>Root cause:
>java.lang.ClassNotFoundException: Unable to load class Driver
> at
>org.apache.jasper.runtime.JspLoader.findClass(JspLoader.java:184)
> at
>org.apache.jasper.runtime.JspLoader.loadClass(JspLoader.java:136)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
> at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313)
> at java.lang.Class.forName0(Native Method)
> at java.lang.Class.forName(Class.java:120)
> at
>jsp.jean._0002fjsp_0002fjean_0002fDBtest_0002ejspDBtest_jsp_0._jspService(_0
>002fjsp_0002fjean_0002fDBtest_0002ejspDBtest_jsp_0.java:72)
> at
>org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:126)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> at
>org.apache.jasper.runtime.JspServlet$JspServletWrapper.service(JspServlet.ja
>va:174)
> at
>org.apache.jasper.runtime.JspServlet.serviceJspFile(JspServlet.java:261)
> at
>org.apache.jasper.runtime.JspServlet.service(JspServlet.java:369)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> at
>org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:503)
> at
>org.apache.tomcat.core.ContextManager.service(ContextManager.java:559)
> at
>org.apache.tomcat.service.connector.Ajp12ConnectionHandler.processConnection
>(Ajp12ConnectionHandler.java:156)
> at
>org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoint.java:338
>)
> at java.lang.Thread.run(Thread.java:484)
>
>Thanks
>
>===========================================================================
>To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
>JSP-INTEREST".
>Some relevant FAQs on JSP/Servlets can be found at:
>
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.html
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
>
>===========================================================================
>To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
>JSP-INTEREST".
>Some relevant FAQs on JSP/Servlets can be found at:
>
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.html
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
Share information about yourself, create your own public profile at
http://profiles.msn.com.
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets