当前位置:首页
开发技术指南» 文章正文
    引言:
 

 

 ·文件读写异常    »显示摘要«
    摘要: import java.io.*; class readfile { public static void main(string args[]) throws exception { //string ss="d:\\temp\\test.java"; //file readfile = new file(ss); stringbuffer stfdir = new......
    摘要: 请各位高手指点一下,在那可以免费下载windows ce4.0(pocket pc2002)? ......


关于关闭数据库的问题

我的数据库连接用的是javabean  
  我在引用javabean的页中关闭数据库  
  <%  
  rs.close();  
  stmt.close();  
  conn.close();  
  %>  
  就会报错!  
  Generated   servlet   error:  
          [javac]   Since   fork   is   true,   ignoring   compiler   setting.  
          [javac]   Compiling   1   source   file  
          [javac]   Since   fork   is   true,   ignoring   compiler   setting.  
          [javac]   D:\Tomcat   4\work\Standalone\localhost\test\online\stusignform_jsp.java:129:   cannot   resolve   symbol  
          [javac]   symbol     :   variable   rs    
          [javac]   location:   class   org.apache.jsp.stusignform_jsp  
          [javac]   rs.close();  
          [javac]   ^  
          [javac]   D:\Tomcat   4\work\Standalone\localhost\test\online\stusignform_jsp.java:130:   cannot   resolve   symbol  
          [javac]   symbol     :   variable   stmt    
          [javac]   location:   class   org.apache.jsp.stusignform_jsp  
          [javac]   stmt.close();  
          [javac]   ^  
          [javac]   D:\Tomcat   4\work\Standalone\localhost\test\online\stusignform_jsp.java:131:   cannot   resolve   symbol  
          [javac]   symbol     :   variable   conn    
          [javac]   location:   class   org.apache.jsp.stusignform_jsp  
          [javac]   conn.close();  
          [javac]   ^  
          [javac]   Note:   D:\Tomcat   4\work\Standalone\localhost\test\online\stusignform_jsp.java   uses   or   overrides   a   deprecated   API.  
          [javac]   Note:   Recompile   with   -deprecation   for   details.  
          [javac]   3   errors  
   
  用javabean怎么关闭数据库链接啊?

NO.1   作者: bisslot

package   DBean;  
  import   java.util.*;  
  import   java.sql.*;  
   
  public   class   sample{  
   
          private   java.sql.Connection   conn   =   null;  
          private   java.sql.Statement     stmt   =   null;  
          private   java.sql.ResultSet     rset   =   null;  
             
        /*     这里是开启连接的方法     */  
          public   void   connectToDB(){  
                       
                        try{  
   
                                Class.ForName("....");  
                                conn   =   DriverManager("..","..","..");  
         
                        }catch(java.lang.NotClassFoundException   ex){  
                                System.err.print("ConnectoToDB()   err:"   +   ex.toString());  
                        }                
                  }  
         
          /*     关闭连接的方法*/  
          public   void   disconnectToDB()   thorws    
              java.sql.SQLException{  
                               
                        if(rset!=null)  
                            {  
                                    rset.close();  
                                    rset   =   null;      
                              }        
                         
                        if(stmt!=null){  
                                    stmt.close();  
                                    stmt   =   null;      
                              }  
   
                        if(conn!=null)  
                            {  
                                    conn.close();  
                                    conn   =   null;      
                              }    
                  }  
  }


    摘要: 1、第一个问题,这有什么用? 2、在程序上如何实现? 3、如果用asp+sql2000如何来实现? ......
» 本期热门文章:

©2000-2007 All Rights Reserved. 最佳浏览:1024X768 MSIE