日期:2014-05-17  浏览次数:20722 次

JSP连接数据库问题?先谢谢各位!!!
代码部分
Java code
Connection conn = null;
 String driver = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
 //String driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
 String url = "jdbc:microsoft:sqlserver://168.57.5.10:1433;DatabaseName=NetBank";
 String name = "sa";
 String pass = "123456";
//连接数据库的方法
try
{
System.out.println("***加载数据库驱动***");
Class.forName(driver);
System.out.println("***数据库驱动加载成功***");
System.out.println("***连接数据库***");
conn = DriverManager.getConnection(url, name, pass);
System.out.println("***数据库连接成功***");

} catch (ClassNotFoundException ce)
{
System.out.println("找不到jar驱动包或者驱动连接字符出错!");
ce.printStackTrace();
} catch (SQLException se)
{
System.out.println("SQL连接字符串出错!");
se.printStackTrace();
} catch (Exception e)
{
e.printStackTrace();
}



提示的错误:
***加载数据库驱动***
***数据库驱动加载成功***
***连接数据库***
SQL连接字符串出错!
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.
at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
at com.microsoft.jdbc.sqlserver.tds.TDSConnection.<init>(Unknown Source)
at com.microsoft.jdbc.sqlserver.SQLServerImplConnection.open(Unknown Source)
at com.microsoft.jdbc.base.BaseConnection.getNewImplConnection(Unknown Source)
at com.microsoft.jdbc.base.BaseConnection.open(Unknown Source)
at com.microsoft.jdbc.base.BaseDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at org.apache.jsp.dbsconn_jsp._jspService(dbsconn_jsp.java:99)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:384)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:228)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:216)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:634)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445)
at java.lang.Thread.run(Thread.java:619)


------解决方案--------------------
程序没毛病

说下 一个java程序员要学习那些东东啊解决办法