做了例子,不是很懂
其中在servlet调用方法连接数据库。代码如下
public Connection getconnection()
{
Connection connection=null;
try {
Class.forName("net.sourceforge.jtds.jdbc.Driver").newInstance();
String url = "jdbc:jtds:sqlserver://localhost:1433/db";
String user = "sa";
String password = "sa";
connection = DriverManager.getConnection(url, user, password);
}
catch (Exception ex) {
System.out.println("创建数据库连接失败!!!!!!!!!!!!!!!");
ex.printStackTrace();
}
return connection;
}
当页面请求的时候(是用xmlhttp发送的请求),如果请求频率一快。。就会出现下面的错误...
java.sql.SQLException: Operation timed out: connect
at net.sourceforge.jtds.jdbc.TdsUtil.getSQLException(TdsUtil.java:181)
at net.sourceforge.jtds.jdbc.TdsUtil.getSQLException(TdsUtil.java:160)
at net.sourceforge.jtds.jdbc.TdsConnection.<init>(TdsConnection.java:182
)
at net.sourceforge.jtds.jdbc.Driver.getConnection(Driver.java:104)
at net.sourceforge.jtds.jdbc.Driver.connect(Driver.java:85)
at java.sql.DriverManager.getConnection(DriverManager.java:512)
at java.sql.DriverManager.getConnection(DriverManager.java:172)
at dbt.dbop.getconnection(dbop.java:67)
at dbt.dbop.<init>(dbop.java:30)
at jcsj.country_ajax.doQuery(country_ajax.java:75)
at jcsj.country_ajax.doPost(country_ajax.java:53)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run
(ServletStubImpl.java:1075)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:418)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:306)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationActio
n.run(WebAppServletContext.java:5517)
at weblogic.security.service.SecurityServiceManager.runAs(SecurityServic
eManager.java:685)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppSe
rvletContext.java:3156)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestIm
pl.java:2506)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:234)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:210)
<2006-9-1 上午08时58分20秒> <Error> <HTTP> <101017> <[ServletContext(id=3699864,
name=DefaultWebApp,context-path=)] Root cause of ServletException
java.lang.NullPointerException
at dbt.dbop.getdata(dbop.java:154)
at jcsj.country_ajax.doQuery(country_ajax.java:77)
at jcsj.country_ajax.doPost(country_ajax.java:53)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run
(ServletStubImpl.java:1075)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:418)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:306)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationActio
n.run(WebAppServletContext.java:5517)
at weblogic.security.service.SecurityServiceManager.runAs(SecurityServic
eManager.java:685)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppSe
rvletContext.java:3156)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestIm
pl.java:2506)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:234)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:210)
>
哪位高手帮着看看是什么问题,不胜感激~~~~~~~~~~
其中在servlet调用方法连接数据库。代码如下
public Connection getconnection()
{
Connection connection=null;
try {
Class.forName("net.sourceforge.jtds.jdbc.Driver").newInstance();
String url = "jdbc:jtds:sqlserver://localhost:1433/db";
String user = "sa";
String password = "sa";
connection = DriverManager.getConnection(url, user, password);
}
catch (Exception ex) {
System.out.println("创建数据库连接失败!!!!!!!!!!!!!!!");
ex.printStackTrace();
}
return connection;
}
当页面请求的时候(是用xmlhttp发送的请求),如果请求频率一快。。就会出现下面的错误...
java.sql.SQLException: Operation timed out: connect
at net.sourceforge.jtds.jdbc.TdsUtil.getSQLException(TdsUtil.java:181)
at net.sourceforge.jtds.jdbc.TdsUtil.getSQLException(TdsUtil.java:160)
at net.sourceforge.jtds.jdbc.TdsConnection.<init>(TdsConnection.java:182
)
at net.sourceforge.jtds.jdbc.Driver.getConnection(Driver.java:104)
at net.sourceforge.jtds.jdbc.Driver.connect(Driver.java:85)
at java.sql.DriverManager.getConnection(DriverManager.java:512)
at java.sql.DriverManager.getConnection(DriverManager.java:172)
at dbt.dbop.getconnection(dbop.java:67)
at dbt.dbop.<init>(dbop.java:30)
at jcsj.country_ajax.doQuery(country_ajax.java:75)
at jcsj.country_ajax.doPost(country_ajax.java:53)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run
(ServletStubImpl.java:1075)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:418)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:306)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationActio
n.run(WebAppServletContext.java:5517)
at weblogic.security.service.SecurityServiceManager.runAs(SecurityServic
eManager.java:685)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppSe
rvletContext.java:3156)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestIm
pl.java:2506)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:234)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:210)
<2006-9-1 上午08时58分20秒> <Error> <HTTP> <101017> <[ServletContext(id=3699864,
name=DefaultWebApp,context-path=)] Root cause of ServletException
java.lang.NullPointerException
at dbt.dbop.getdata(dbop.java:154)
at jcsj.country_ajax.doQuery(country_ajax.java:77)
at jcsj.country_ajax.doPost(country_ajax.java:53)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run
(ServletStubImpl.java:1075)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:418)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:306)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationActio
n.run(WebAppServletContext.java:5517)
at weblogic.security.service.SecurityServiceManager.runAs(SecurityServic
eManager.java:685)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppSe
rvletContext.java:3156)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestIm
pl.java:2506)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:234)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:210)
>
哪位高手帮着看看是什么问题,不胜感激~~~~~~~~~~
解决方案 »
- 请教高手看几行bubble sort的代码,谢谢
- 请教关于http抓包
- 求救,JNative调用dll函数如何取得内存里的数据
- java的class(二进制文件)怎么到别的电脑上用?????
- 这个this是什么作用?如果不这样写还可以怎样?
- 如何在程序中调用系统的目录选择 (即加入"浏览"键)
- eclipse的配置问题,急等!
- 怎样在java中实现查看系统(非JVM)的内存(已用?空闲?),cpu使用情况(已用?空闲?).好急呀...
- java io 的问题 ,大家帮帮初学者
- 请问,哪里有JavaMail API的源码下载?
- 按鼠标左键,光标移动的event.keyCode=???
- GZIPInputStream和ZipInputStream的区别
看看你的数据库的配置是不是正确的,比如端口是不是1433