JDBC一直连不上MS SQL SERVER 2K!

chaoyueBetter 2003-11-10 11:14:19
0,test.jsp....locate at the Webapps/examples/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://127.0.0.1:1433;DatabaseName=pubs";
//pubs为你的数据库的
String user="sa";
String password="";
Connection conn= DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql="select * from sales";
ResultSet rs=stmt.executeQuery(sql);
while(rs.next()) {%>
您的第一个字段内容为:<%=rs.getString(1)%>
您的第二个字段内容为:<%=rs.getString(2)%>
<%}%>
<%out.print("数据库操作成功,恭喜你");%>
<%rs.close();
stmt.close();
conn.close();
%>
</body>
</html>
1,error report...
=======================================
HTTP Status 500 -

-----------------------------------------------

type Exception report

message

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

exception

org.apache.jasper.JasperException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:254)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke



-------------------------------------------------
Apache Tomcat/4.1.29-LE-jdk14
2,classpath=.;c:\program files\ms...\msbase.jar...
3,copy the three msbase.jar...mssqlserver.jar to the %catalina_home/common/lib/


how a noise thing about the JDBC for MS SQL server!
...全文
18 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
chaoyueBetter 2003-11-10
  • 打赏
  • 举报
回复
thx!
i was devasted by it through the all night.

now,i have solved this fuck noising problem by myself,haheh.

i gona http://www.microsoft.com/sql/ for refering to something valuable,and finnally i didn't radiculously upgrade my sql server to sp3....

what a pity.

and thx for the helper!

and how to distribute the scores,give your opinion!
giftxi 2003-11-10
  • 打赏
  • 举报
回复
String url="jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=pubs";
你的数据库是不是在本机上就有,IP别搞错。
Leemaasn 2003-11-10
  • 打赏
  • 举报
回复
你的mssql数据库服务器的端口可能不是1433,或者改变了。。。
ok281 2003-11-10
  • 打赏
  • 举报
回复
String url="jdbc:microsoft:sqlserver://localhost:1433";
String user="sa";
String password="";
在数据库中给sa指定pubs即可
aku0708 2003-11-10
  • 打赏
  • 举报
回复
你有没有把JDBC驱动加进去了吗
dengyin2000 2003-11-10
  • 打赏
  • 举报
回复
restart you computer!!

81,091

社区成员

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

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