日期:2014-05-20  浏览次数:20661 次

不断操作数库,怎样做效率最好?在线等。。代码做参考?最好写一个最好方案给我。谢谢
public class InsertData implements Runnable{
Connection conn; 
java.sql.Statement st = null;
public   void run() { 
 while (true ) { 
 try {
        conn = DBConnection.getDBC();
        st = conn.createStatement();
             st.executeUpdate(sql);
      
                } catch (Exception e) {
           try{
             conn.rollback();
             } catch(Exception e1){}
        } finally {
         try{ 
         st.close();
             conn.close();
             } catch(Exception e){}
        }

 }
================

public class InsertData implements Runnable{
Connection conn; 
java.sql.Statement st = null;
conn = DBConnection.getDBC();
   st = conn.createStatement();
        boolean sign=true;
public   void run() { 
 while (true) { 
 try {
if(sign==false){
conn = DBConnection.getDBC();
    st = conn.createStatement();
sign=true;
 }         
    
st.executeUpdate(sql);
      
 } catch (Exception e)
 {
         st.close();
 conn.close();
 sign=false;  
        }

}