jsp连接数据库问题
<%@ page contentType= "text/html; charset=gb2312 " language= "java " import= "java.sql.* "
errorPage= "exception.jsp " %>
<html>
<body>
<%/***********************************************
/*
/*DbTest.java
/*http://www.knowsky.com
/******************************************* */
public class DbTest {
Connection con;
Statement sta;
ResultSet rs;
String driver;
String url;
String user;
String pwd;
public DbTest()
{
driver = "com.microsoft.jdbc.sqlserver.SQLServerDriver ";;
url = "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName =guolv ";
user = "sa ";
pwd = "pass ";
init();
}
public void init()
{
try{
Class.forName(driver);
System.out.println( "driver is ok ");
con = DriverManager.getConnection(url,user,pwd);
System.out.println( "conection is ok ");
sta = con.createStatement();
rs = sta.executeQuery( "select * from logonerr ");
while(rs.next())
System.out.println(rs.getInt( "id "));
}catch(Exception e)
{
e.printStackTrace();
}
}
public static void main(String args [])//自己替换[]
{
new DbTest();
}
}
%>
</body>
</html>
以上是代码
下面是错误代码
刚学习jsp 不怎么看的懂
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: org.apache.jasper.
JasperException: Unable to load class for JSP
org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:156)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:329)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause
org.apache.jasper.JasperException: Unable to load class for JSP
org.apache.jasper.JspCompilationContext.load(JspCompilationContext.java:600)
org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:144)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:329)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause