连接数据库的小问题,急救~~

不住不执 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>
...全文
52 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
aku0708 2003-12-01
  • 打赏
  • 举报
回复
One way of connecting to a database is through the JDBC driver manager using the method DriverManager.getConnection. This method uses a string containing a URL. The following is an example of using the JDBC driver manager to connect to Microsoft SQL Server 2000 while passing the user name and password:

Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
Connection conn = DriverManager.getConnection
("jdbc:microsoft:sqlserver://server1:1433;User=test;Password=secret");
chouchy 2003-12-01
  • 打赏
  • 举报
回复
写错了,Statement不是Statment
lu8088 2003-12-01
  • 打赏
  • 举报
回复
不懂,学习,我是连oracle的。
sensory 2003-12-01
  • 打赏
  • 举报
回复
Statment 错误
romeoyx 2003-12-01
  • 打赏
  • 举报
回复
同意quaker1234(林夕) 和 noratong(诺拉) 两位
hojay2001 2003-12-01
  • 打赏
  • 举报
回复
你是否安装了sql2000的jdbc驱动?
要把安装生成的三个文件放到tomcathome\common\lib\下
noratong 2003-11-30
  • 打赏
  • 举报
回复
楼上的说的对,是Statement,错误信息里面已经指示的很明确了.

仔细看错误信息.
quaker1234 2003-11-30
  • 打赏
  • 举报
回复
Statment stmt;


Statement stmt;
不住不执 2003-11-30
  • 打赏
  • 举报
回复
还是web.xml中需要配置什么东西吗?

不住不执 2003-11-30
  • 打赏
  • 举报
回复
tomcat还需要装什么东西吗?
不住不执 2003-11-30
  • 打赏
  • 举报
回复
加上了这个,还是错啊,哪位大哥快来救救兄弟啊~

Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");

=====
ExplorerCSharp 2003-11-30
  • 打赏
  • 举报
回复
Class.forName( "com.microsoft.jdbc.sqlserver.SQLServerDriver");
不住不执 2003-11-30
  • 打赏
  • 举报
回复
呀,疯了,我看到了,忘乐点东西。。。。。

81,095

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧