日期:2014-05-18  浏览次数:20704 次

JSP中数据库的连接问题(急~!)
在安装完JDK1.5和TOMCAT5.0后,启动SQLSERVER2000,做个数据库连接测试。测试页名为:index.jsp;代码如下;

<%@   page   contentType= "text/html;   charset=gb2312 "%>
<%@   page   import= "java.sql.* "   %>
<html>
<head>
<title> jsptest </title>
</head>
<body>
<%
//request.setCharacterEncoding( "gb2312 ");
//String   username=request.getParameter( "username ");
//String   password=request.getParameter( "password ");
Class.forName( "com.microsoft.jdbc.sqlserver.SQLServerDriver ").newInstance();
String   url= "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=jsptest ";
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   isCorrect= "select   *   from   users ";
ResultSet   rs=stmt.executeQuery(isCorrect);

while(rs.next())
{%>
第1个字节是: <%=rs.getString(1)%>
第2个字节是: <%=rs.getString(2)%>
<%}
%>
<%
out.print( "you   are   successful~! ");
%>
<%
rs.close();
stmt.close();
conn.close();
%>

//if(!rs.next())
//{
// response.sendRedirect( "loginsuccess.jsp ");
// rs.close();
// stmt.close();
// conn.close();
//}
//else
//{
// response.sendRedirect( "login.jsp ");
//}
</body>
</html>

但结果出现了500错:description   The   server   encountered   an   internal   error   ()   that   prevented   it   from   fulfilling   this   request.

是不是还要配置什么server.xml等呀??

请帮忙回答下,谢谢了

------解决方案--------------------
打过SQLServer2000的补丁没有?不打补丁1433端口打不开
我的异常网推荐解决方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.aiyiweb.com/java-web/317.html