首页上一页 1 下一页尾页 10 条记录 1/1页
java程序设计自学手册 20章blog系统的相关问题
发表在Java图书答疑
2008-12-02
是否精华
是
否
版块置顶:
是
否
设置时间:
非永久
永久
起始时间:
结束时间:
是否扣分:
是
否
第20章的blog系统 在输入用户名mr和密码mrsoft后 出现如下错误
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
java.lang.NullPointerException
com.wy.tool.JDBConnection.executeQuery(JDBConnection.java:52)
com.wy.dao.ConsumerDao.getConsumerForm(ConsumerDao.java:100)
com.wy.webiter.ConsumerServlet.checkConsumer(ConsumerServlet.java:187)
com.wy.webiter.ConsumerServlet.doGet(ConsumerServlet.java:32)
com.wy.webiter.ConsumerServlet.doPost(ConsumerServlet.java:204)
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.16 logs.
--------------------------------------------------------------------------------
如何解决呢??
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
java.lang.NullPointerException
com.wy.tool.JDBConnection.executeQuery(JDBConnection.java:52)
com.wy.dao.ConsumerDao.getConsumerForm(ConsumerDao.java:100)
com.wy.webiter.ConsumerServlet.checkConsumer(ConsumerServlet.java:187)
com.wy.webiter.ConsumerServlet.doGet(ConsumerServlet.java:32)
com.wy.webiter.ConsumerServlet.doPost(ConsumerServlet.java:204)
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.16 logs.
--------------------------------------------------------------------------------
如何解决呢??
精彩评论 10
2008-12-05
5L
现在我换成使用ODBC建立数据源的方法 输入用户名mr和密码mrsoft后成功了
但我试了下使用JDBC是方法无法与sql建立连接的
可我也把驱动放到lib文件夹下了啊 我用mysql时都没问题的
怎样才能使用JDBC的方法成功连接sql呢?
以下是我用JDBC连接的错误
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: An exception occurred processing JSP page /sqlserver.jsp at line 16
13: String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=db_BlodMay";
14: String user="sa";
15: String password="";
16: Connection conn= DriverManager.getConnection(url,user,password);
17: conn.close();
18: %>
19: </body>
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:505)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:398)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause
javax.servlet.ServletException: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:850)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:779)
org.apache.jsp.sqlserver_jsp._jspService(sqlserver_jsp.java:81)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
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(Unknown Source)
java.sql.DriverManager.getConnection(Unknown Source)
org.apache.jsp.sqlserver_jsp._jspService(sqlserver_jsp.java:69)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.16 logs.
但我试了下使用JDBC是方法无法与sql建立连接的
可我也把驱动放到lib文件夹下了啊 我用mysql时都没问题的
怎样才能使用JDBC的方法成功连接sql呢?
以下是我用JDBC连接的错误
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: An exception occurred processing JSP page /sqlserver.jsp at line 16
13: String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=db_BlodMay";
14: String user="sa";
15: String password="";
16: Connection conn= DriverManager.getConnection(url,user,password);
17: conn.close();
18: %>
19: </body>
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:505)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:398)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause
javax.servlet.ServletException: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:850)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:779)
org.apache.jsp.sqlserver_jsp._jspService(sqlserver_jsp.java:81)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
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(Unknown Source)
java.sql.DriverManager.getConnection(Unknown Source)
org.apache.jsp.sqlserver_jsp._jspService(sqlserver_jsp.java:69)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.16 logs.
2008-12-09
8L
既然你打了 sp4补丁,出现这样的问题,我觉得有两个原因:
一、你的程序代码有问题,下面是你的代码,可能不是你全部的代码,但你在与数据库获取连接后,又将连接关闭(conn.close();),这样使你在其他数据库操作时,不成功。
13: String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=db_BlodMay";
14: String user="sa";
15: String password="";
16: Connection conn= DriverManager.getConnection(url,user,password);
17: conn.close();
18: %>
二、你数据库的1433端口不开
一、你的程序代码有问题,下面是你的代码,可能不是你全部的代码,但你在与数据库获取连接后,又将连接关闭(conn.close();),这样使你在其他数据库操作时,不成功。
13: String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=db_BlodMay";
14: String user="sa";
15: String password="";
16: Connection conn= DriverManager.getConnection(url,user,password);
17: conn.close();
18: %>
二、你数据库的1433端口不开