问题描述
连接数据库的文件源码:dataconn.javapackagedataconn;importjava.sql.*;publicclassdataconn{StringsConnStr="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=BugFree";Stringuser="sa";Stringpassword="sa";Connectionconn=null;Statementstmt=null;ResultSetrs=null;publicdataconn(){try{Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");}catch(java.lang.ClassNotFoundExceptione){System.err.println("news_conn():"+e.getMessage());}}publicResultSetexecuteQuery(Stringsql){rs=null;try{conn=DriverManager.getConnection(sConnStr,user,password);stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);rs=stmt.executeQuery(sql);}catch(SQLExceptionex){System.err.println("aq.executeQuery:"+ex.getMessage());System.err.println("aq.executeQuerystrSQL:"+sql);}returnrs;}//执行一些创建Table的语句。publicvoidexecute(Stringsql){try{conn=DriverManager.getConnection(sConnStr,user,password);stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);stmt.execute(sql);}catch(SQLExceptionex){System.err.println("aq.executeUpdate:"+ex.getMessage());System.err.println("aq.executeUpadatestrSQL:"+sql);}}publicvoidcloseStmt(){try{stmt.close();}catch(SQLExceptione){e.printStackTrace();}}publicvoidcloseConn(){try{conn.close();}catch(SQLExceptione){e.printStackTrace();}}}一个使用全局临时表的jsp页面,源码<%dataconnconn=newdataconn();conn.execute("ifobject_id('#temp')isnotnulldroptable#temp");conn.execute("createtable#temp(BugIDint,BugTitlevarchar(100))");conn.execute("insertinto#tempselectBugID,BugTitlefromBugInfo");ResultSetrs=conn.executeQuery("select*from#tempwhereBugID>42");if(rs!=null){while(rs.next()){out.print(rs.getString("BugID"));out.print(rs.getString("BugTitle"));out.println();}}rs.close();conn.close();%>只要连续刷新两次这个jsp页面,myeclipse会自动跳动debug,出现下面提示DaemonThread[http-8080-4](Suspended(exceptionSQLException))TDSExecuteRequest(TDSRequest).processReply(BaseWarnings)line:notavailableSQLServerImplStatement.getNextResultType()line:notavailableBaseStatement.commonTransitionToState(int)line:notavailableBaseStatement.postImplExecute(boolean)line:notavailableBaseStatement.commonExecute()line:notavailableBaseStatement.executeInternal()line:notavailableBaseStatement.execute(String)line:notavailableDelegatingStatement.execute(String)line:261TempTableManage.CreateTempTable(String)line:51MyJsp.jspline:35MyJsp_jsp(HttpJspBase).service(HttpServletRequest,HttpServletResponse)line:70MyJsp_jsp(HttpServlet).service(ServletRequest,ServletResponse)line:803JspServletWrapper.service(HttpServletRequest,HttpServletResponse,boolean)line:384JspServlet.serviceJspFile(HttpServletRequest,HttpServletResponse,String,Throwable,boolean)line:320JspServlet.service(HttpServletRequest,HttpServletResponse)line:266JspServlet(HttpServlet).service(ServletRequest,ServletResponse)line:803ApplicationFilterChain.internalDoFilter(ServletRequest,ServletResponse)line:290ApplicationFilterChain.doFilter(ServletRequest,ServletResponse)line:206SetCharacterEncodingFilter.doFilter(ServletRequest,ServletResponse,FilterChain)line:123ApplicationFilterChain.internalDoFilter(ServletRequest,ServletResponse)line:235ApplicationFilterChain.doFilter(ServletRequest,ServletResponse)line:206StandardWrapperValve.invoke(Request,Response)line:228StandardContextValve.invoke(Request,Response)line:175StandardHostValve.invoke(Request,Response)line:128ErrorReportValve.invoke(Request,Response)line:104StandardEngineValve.invoke(Request,Response)line:109CoyoteAdapter.service(Request,Response)line:216Http11Processor.process(Socket)line:844Http11Protocol$Http11ConnectionHandler.process(Socket)line:634JIoEndpoint$Worker.run()line:445Thread.run()line:notavailable对于上面的问题,我google查询了,但是没有得到好的解方案。希望大家能够给予帮助!
解决方案
解决方案二:
#temp是局部临时表##temp才是全局临时表局部临时表只属于创建它的哪个会话