jsp连接SQL server 2000 的问题?(肯请大家看看)
jsp连接SQL server 2000 的问题?(肯请大家看看)
下载软件:
jsdk1.42+Tomcat/5.0.27+SQL Server 2000企业版+SQL Server 2000 Driver for JDBC Service Pack 3
环境变量:
CATALINA_BASEjava_home=c:\j2sdk_nb
classpath=.;%java_home%\lib\dt.jar;%java_home%\lib\tools.jar;%CATALINA_HOME%\common\lib\servlet-api.jar;%JDBC_INSTALL_PATH%\lib\msbase.jar;%JDBC_INSTALL_PATH%\lib\mssqlserver.jar;%JDBC_INSTALL_PATH%\msutil.jar
path= C:\j2sdk_nb\bin;
CATALINA_HOME=c:\Tomcat;
CATALINA_BASE=c:\Tomcat;
JDBC_INSTALL_PATH=D:\soft\jdbc_sql2000
自检的过程:
1,看看TOMCAT服务器启动是否正常!-----------------------启动正常
2。看看TOMCAT服务器中连接SQL3个驱动包是否被注册成功--------------上面已经加到环境变量中
3。看看数据库服务器是否正常启动!--------------------------启动正常
如下一个程序:
<%@ page contentType="text/html;charset=gb2312"%>;
<%@ page import="java.sql.*"%>;
<html>;
<body>;
<%
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=data";
String user="sa";
String password="123";
Connection conn= DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql="select * from test_one";
ResultSet rs=stmt.executeQuery(sql);
while(rs.next())
{
%>;
您的第一个字段内容为:<%=rs.getString(1)%>;
您的第二个字段内容为:<%=rs.getString(2)%>;
<%
}
%>;
<%out.print("数据库操作成功,恭喜你");%>;
<%
rs.close();
stmt.close();
conn.close();
%>;
</body>;
</html>;
调试后出现如下错误:HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]?????? 'data' ?????????????
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
org.apache.jsp._222_jsp._jspService(_222_jsp.java:113)
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
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]?????? 'data' ?????????????
com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
com.microsoft.jdbc.sqlserver.tds.TDSRequest.processErrorToken(Unknown Source)
com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReplyToken(Unknown Source)
com.microsoft.jdbc.sqlserver.tds.TDSLoginRequest.processReplyToken(Unknown Source)
com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReply(Unknown Source)
com.microsoft.jdbc.sqlserver.SQLServerImplConnection.open(Unknown Source)
com.microsoft.jdbc.base.BaseConnection.getNewImplConnection(Unknown Source)
com.microsoft.jdbc.base.BaseConnection.open(Unknown Source)
com.microsoft.jdbc.base.BaseDriver.connect(Unknown Source)
java.sql.DriverManager.getConnection(DriverManager.java:512)
java.sql.DriverManager.getConnection(DriverManager.java:171)
org.apache.jsp._222_jsp._jspService(_222_jsp.java:61)
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)
note The full stack trace of the root cause is available in the Apache Tomcat/5.0.27 logs.