Topic: 救命啊~~~JSP连接SQL数据库的问题~

  Print this page

1.救命啊~~~JSP连接SQL数据库的问题~ Copy to clipboard
Posted by: naughty009
Posted on: 2005-09-24 20:54

以下是我的JSP:
<%@ 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=pubs";

String user="sa";

String password="";

Connection conn= DriverManager.getConnection(url,user,password);

Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);

%>

<%out.print("数据库操作成功,恭喜你");%>

<%

stmt.close();

conn.close();

%>

</body>

</html>
出现的错误是:

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:825)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
org.apache.jsp.connsql_jsp._jspService(connsql_jsp.java:89)
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]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.<init>(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.connsql_jsp._jspService(connsql_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.28 logs.

我将mssqlserver.jar,msbase.jar,msutil.jar都放在我的网站目录的WEB-INF\lib下了,
还是不行啊,只放mssqlserver.jar这个就出现
以下错误:

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: com/microsoft/jdbc/base/BaseDriver
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
org.apache.jsp.connsql_jsp._jspService(connsql_jsp.java:89)
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.lang.NoClassDefFoundError: com/microsoft/jdbc/base/BaseDriver
java.lang.ClassLoader.defineClass0(Native Method)
java.lang.ClassLoader.defineClass(ClassLoader.java:537)
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1634)
org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:860)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1307)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1189)
org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:148)
org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:69)
java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
java.lang.Class.forName0(Native Method)
java.lang.Class.forName(Class.java:141)
org.apache.jsp.connsql_jsp._jspService(connsql_jsp.java:53)
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.28 logs.

我只想实现连接成功而已~
请大虾们帮帮手啊~~~~~~~

2.Re:救命啊~~~JSP连接SQL数据库的问题~ [Re: naughty009] Copy to clipboard
Posted by: YuLimin
Posted on: 2005-09-25 22:51

Error establishing socket.

记得把SQL的SP3打上去就可以了。

3.Re:救命啊~~~JSP连接SQL数据库的问题~ [Re: naughty009] Copy to clipboard
Posted by: why
Posted on: 2005-09-26 17:06

Search here http://www.cjsdn.net/post/search
with keywords "Error establishing socket"

4.Re:救命啊~~~JSP连接SQL数据库的问题~ [Re: naughty009] Copy to clipboard
Posted by: naughty009
Posted on: 2005-09-26 20:23

谢谢啦~!这个问题已经解决~~~~~

5.Re:救命啊~~~JSP连接SQL数据库的问题~ [Re: naughty009] Copy to clipboard
Posted by: YuLimin
Posted on: 2005-09-27 12:25

解决的方法是怎么样的,是不是跟我们解决的方法不一样?
如果不一样请写出你的经验,大家一起学习:)

6.Re:救命啊~~~JSP连接SQL数据库的问题~ [Re: naughty009] Copy to clipboard
Posted by: naughty009
Posted on: 2005-09-27 12:47

打上sp3根本没用~~~~重装了系统吖~痛苦啊~~~~~~~再重装sql就行了~~~~唉~!都不知是什么回事啊~!

7.Re:救命啊~~~JSP连接SQL数据库的问题~ [Re: naughty009] Copy to clipboard
Posted by: flyingqifei
Posted on: 2005-09-27 23:05

SP3还是要打的,现在新出了SP4,不是重装系统这么痛苦吧!那也没找着原因呀!以后再碰到岂不……


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2018 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号
客服电话 0592-8750026    客服信箱 714923@qq.com    客服QQ 714923