[求助]JSP連線SQL Server 2000問題,看了很多資料還未解決,求救!
本機環境:WinXP +SP2 JDK1.5.0 Tomcat5.0.16 SQL Server 2000(XP下能用的那種版本)
已裝了SQL Server 2000 Driver for JDBC Service Pack 3,並且已經把msbase.jar,mssqlserver.jar,msutil.jar複製到Tomcat目錄下common\lib目錄下,之後,修改環境變數中的CLASSPATH,
把SQL Server 2000 For JDBC 驅動程式安裝目錄下的
C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\msbase.jar;
C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\mssqlserver.jar;
C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\msutil.jar;
追加到CLASSPATH中去。
JDK和Tomcat 測試後都能正常執行,JavaBean,Servlet都測試能正常執行。
用於測試連線資料庫的程式碼如下:
<%-- 使用JDBC驅動直接訪問SQLServer2000資料庫. --%>
<%@ page contentType = "text/html; charset = gb2312" language = "java" import = "java.sql.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd" >
<html>
<head>
<title>
use JDBC to connect SQL Server
</title>
<style type = "text/css">
<!--
.style{
color:FF0000;
font-size:24px;
}
-->
</style>
</head>
<body>
<div align = "center" ><span class = "style1" > JDBC access SQL Server directly </span><BR></div>
<hr><br>
<table border = 2 bordercolor = "FF0000" align = "center">
<tr>
<td> au_id </td>
<td> au_lname </td>
<td> au_fname </td>
<td> phone </td>
<td> address </td>
<td> city </td>
<td> state </td>
<td> zip </td>
<td> contract </td>
<tr>
<%
Class.forName( "com.microsoft.jdbc.sqlserver.SQLServerDriver" ).newInstance();
String url = "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName = pubs";
String user = "yc";
String password = "123";
Connection conn = DriverManager.getConnection( url, user, password );
Statement stmt = conn.createStatement( ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE );
String sql = "SELECT TOP 10 * FROM authors";
ResultSet rs = stmt.executeQuery( sql );
while( rs.next() ){
%>
<tr>
<td><%= rs.getString( "au_id" ) %></td>
<td><%= rs.getString( "au_lname" ) %></td>
<td><%= rs.getString( "au_fname" ) %></td>
<td><%= rs.getString( "phone" ) %></td>
<td><%= rs.getString( "address" ) %></td>
<td><%= rs.getString( "city" ) %></td>
<td><%= rs.getString( "state" ) %></td>
<td><%= rs.getString( "zip" ) %></td>
<td><%= rs.getString( "contract" ) %>
</tr>
<%}%>
<%
out.print( "Congratulations, The access is successful!" );
rs.close();
stmt.close();
conn.close();
%>
</table>
</body>
</html>
(該程式在其他機器上執行後能連上資料庫)
JSP頁面提示錯誤資訊為:
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]Error establishing socket.
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:867)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:800)
org.apache.jsp.test.E6_jsp._jspService(E6_jsp.java:87)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
root cause
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.
com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
com.microsoft.jdbc.sqlserver.tds.TDSConnection.(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(Unknown Source)
java.sql.DriverManager.getConnection(Unknown Source)
org.apache.jsp.test.E6_jsp._jspService(E6_jsp.java:47)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
note The full stack trace of the root cause is available in the Tomcat logs.
--------------------------------------------------------------------------------
Apache Tomcat/5.0.16
已裝了SQL Server 2000 Driver for JDBC Service Pack 3,並且已經把msbase.jar,mssqlserver.jar,msutil.jar複製到Tomcat目錄下common\lib目錄下,之後,修改環境變數中的CLASSPATH,
把SQL Server 2000 For JDBC 驅動程式安裝目錄下的
C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\msbase.jar;
C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\mssqlserver.jar;
C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\msutil.jar;
追加到CLASSPATH中去。
JDK和Tomcat 測試後都能正常執行,JavaBean,Servlet都測試能正常執行。
用於測試連線資料庫的程式碼如下:
<%-- 使用JDBC驅動直接訪問SQLServer2000資料庫. --%>
<%@ page contentType = "text/html; charset = gb2312" language = "java" import = "java.sql.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd" >
<html>
<head>
<title>
use JDBC to connect SQL Server
</title>
<style type = "text/css">
<!--
.style{
color:FF0000;
font-size:24px;
}
-->
</style>
</head>
<body>
<div align = "center" ><span class = "style1" > JDBC access SQL Server directly </span><BR></div>
<hr><br>
<table border = 2 bordercolor = "FF0000" align = "center">
<tr>
<td> au_id </td>
<td> au_lname </td>
<td> au_fname </td>
<td> phone </td>
<td> address </td>
<td> city </td>
<td> state </td>
<td> zip </td>
<td> contract </td>
<tr>
<%
Class.forName( "com.microsoft.jdbc.sqlserver.SQLServerDriver" ).newInstance();
String url = "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName = pubs";
String user = "yc";
String password = "123";
Connection conn = DriverManager.getConnection( url, user, password );
Statement stmt = conn.createStatement( ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE );
String sql = "SELECT TOP 10 * FROM authors";
ResultSet rs = stmt.executeQuery( sql );
while( rs.next() ){
%>
<tr>
<td><%= rs.getString( "au_id" ) %></td>
<td><%= rs.getString( "au_lname" ) %></td>
<td><%= rs.getString( "au_fname" ) %></td>
<td><%= rs.getString( "phone" ) %></td>
<td><%= rs.getString( "address" ) %></td>
<td><%= rs.getString( "city" ) %></td>
<td><%= rs.getString( "state" ) %></td>
<td><%= rs.getString( "zip" ) %></td>
<td><%= rs.getString( "contract" ) %>
</tr>
<%}%>
<%
out.print( "Congratulations, The access is successful!" );
rs.close();
stmt.close();
conn.close();
%>
</table>
</body>
</html>
(該程式在其他機器上執行後能連上資料庫)
JSP頁面提示錯誤資訊為:
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]Error establishing socket.
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:867)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:800)
org.apache.jsp.test.E6_jsp._jspService(E6_jsp.java:87)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
root cause
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.
com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
com.microsoft.jdbc.sqlserver.tds.TDSConnection.(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(Unknown Source)
java.sql.DriverManager.getConnection(Unknown Source)
org.apache.jsp.test.E6_jsp._jspService(E6_jsp.java:47)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
note The full stack trace of the root cause is available in the Tomcat logs.
--------------------------------------------------------------------------------
Apache Tomcat/5.0.16
相關文章
- JSP連線SQL Server資料庫JSSQLServer資料庫
- [求助]資料庫連線池配置問題資料庫
- 不同網段sql server 2005 連線 sql server 2000的問題SQLServer
- 安裝與ms sql server2000連線問題?SQLServer
- java 連結sql server 2000 問題JavaSQLServer
- sql server 資料庫還原問題SQLServer資料庫
- 用Java連線SQL Server2000資料庫JavaSQLServer資料庫
- jsp連線sql server呼叫資料來源方法 (轉)JSSQLServer
- 怎麼解決SQL server 2000的中文問題?SQLServer
- SQL Server 2000中的資料同步問題SQLServer
- 請教,求助tomcat + MS server2K 資料庫連線池問題TomcatServer資料庫
- SQL Server 2000 死鎖(dead lock) 問題解決SQLServer
- 解決無法連線SQL Server資料庫的方法BWSQLServer資料庫
- 求助:為什麼用jbuilder連sql2000出問題UISQL
- 深入探索MS SQL Server 2000網路連線的安全問題 (轉)SQLServer
- JSP+javaBean連線資料庫的問題JSJavaBean資料庫
- SQL Server 2008連線區域網內的SQL Server 2000資料庫SQLServer資料庫
- 資料庫連線未關閉的問題資料庫
- 求助: 用Hibernate連線多個資料庫的問題?資料庫
- sql server資料庫連線失敗/無法附加解決過程SQLServer資料庫
- 關於jsp 呼叫bean 訪問sql-server資料庫問題JSBeanSQLServer資料庫
- 求救!弄了一天JiveJdon,還是未解決
- 如何建立和還原SQL Server 2000資料庫?SQLServer資料庫
- SQL SERVER 2000 資料庫備份與還原SQLServer資料庫
- Hibernate配置連線SQL SERVER2000SQLServer
- 求助!關於多執行緒連線資料庫的問題執行緒資料庫
- c#連線SQL Server資料庫C#SQLServer資料庫
- SQL server資料庫連線不上SQLServer資料庫
- 求助servlet&jsp問題ServletJS
- ASP.NET2.0連線SQL Server資料庫詳解ASP.NETSQLServer資料庫
- SQL Server連線SQL Server、SQL Server連線ORACLE 連結伺服器SQLServerOracle伺服器
- 資料來源問題求救
- 配置資料庫問題?求救資料庫
- oracle 11g gateway 連線sql server 2000OracleGatewaySQLServer
- 《轉》Sql Server 2005(64位) 連線Sql Server 2000(32位) .SQLServer
- 還原sql server 2000資料庫的坑,不同版本資料庫SQLServer資料庫
- SQL Server 2000 許可權問題SQLServer
- SQL Server 資料庫連線字串的宣告SQLServer資料庫字串