连接数据库的小问题,急救~~
不住不执 2003-11-30 05:48:04 初学jsp做SQLSERVER数据库例子练习时,出现如下错误
环境为:tomcat4.01,lib目录中有微软的3个SQL驱动程序包和j2ee.jar,j2eetools.jar
-------------------------------------
org.apache.jasper.JasperException: Unable to compile class for JSPNote: sun.tools.javac.Main has been deprecated.
An error occured between lines: 9 and 42 in the jsp file: /dbtest.jsp
Generated servlet error:
D:\Program Files\Apache Tomcat 4.0\work\localhost\mytest\dbtest$jsp.java:92: Class org.apache.jsp.Statment not found.
Statment stmt;
^
1 error, 1 warning
------------------
代码
------------------
<%@ page info="database handler" %>
<%@ page import="java.io.*" %>
<%@ page import="java.util.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="javax.servlet.*" %>
<%@ page import="javax.servlet.http.*" %>
<html>
<body>
<%
try
{
Connection con;
Statment stmt;
ResultSet rs;
Class.forName("");
String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=sunone";
String user="sa";
String password="admin";
con=DriverManager.getConnection(url,user,password);
out.println("dfd");
stmt=con.createStatement();
stmt.executeQuery("INSERT INTO member(userID,password) Values('1','2')");
rs=stmt.executeQuery("SELECT userID,password from member");
out.println("<table border=1 width=400>");
while (rs.next())
{
String col1 = rs.getString(1);
String col2 = rs.getString(2);
out.println("<tr><td>" + col1 + "</td><td>" + col2 + "</td></tr>");
}
out.println("</table>");
}
catch(Exception e){
out.println(e);
}
%>
</body>
</html>