关于连接sqlserver数据库问题.很急,清高手指点
我的连接数据库代码是这样(下面)写的,结果一执行连接程序就跳到catch...处了,web页面就出来下面的提示。
public boolean connect(){
try{
Class.forName( "com.microsoft.jdbc.sqlserver.SQLServerDriver ").newInstance();
String url= "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=bookstor ";
String user= " ";
String password= " ";
con=DriverManager.getConnection(url,user,password);
stmt=con.createStatement();
}catch(Exception ee){System.out.println( "connect db error: "+ee.getMessage());
return false;
}
return true;
}
下面是web的错误信息:
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:372)
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.NullPointerException
bookshop.run.login.execute(login.java:69)
org.apache.jsp.login_jsp._jspService(login_jsp.java:71)
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.27 logs.
--------------------------------------------
Apache Tomcat/5.0.27
[解决办法]
String user= " ";
你用得是WINDOWS验证,最好是改为混合验证,
String user= "sa ";
[解决办法]
链接数据库的用户名和密码总得要有的吧。呵呵。就像找到保险柜了但没有密码就打不开罗
我的异常网推荐解决方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.myexception.cn/java-web/317.html