アットウィキロゴ

h2sql

package sql;
import java.sql.*; 
 
class h2insert{ 
 
Connection dbx;   
Statement stx;   
String sqx; 
ResultSet  rsx; 
 
int key; 
String word;
int sx;
  String[] credit=new String[10];
    String[] type=new String[10];
    int creditnumber;
    int tx;
     String[][] data=new String[16000][8];
    int datanumber;
 
 
void makedata(String db,String tab){ 
 
String url = "jdbc:h2:"+db+";create=true";   
String usr = "";   
String pwd = ""; 
 
 
 try
          {
            Class.forName("org.h2.Driver");
 
dbx = DriverManager.getConnection(url, usr, pwd); 
} catch (Exception ex) { ex.printStackTrace();} 
 
 
 
 
try {   
 
int s;    
 
for(s=1;s<datanumber+1;s++){    
sqx="insert into "+tab+" values("; 
for(sx=1;sx<creditnumber;sx++){  
if(type[sx].equals("INTEGER"))sqx=sqx+data[s][sx]+",";
if(type[sx].equals("DOUBLE"))sqx=sqx+data[s][sx]+",";
if(type[sx].equals("VARCHAR"))sqx=sqx+change(data[s][sx])+",";
}
sx=creditnumber;
if(type[sx].equals("INTEGER"))sqx=sqx+data[s][sx];
if(type[sx].equals("DOUBLE"))sqx=sqx+data[s][sx];
if(type[sx].equals("VARCHAR"))sqx=sqx+change(data[s][sx]);
sqx=sqx+")"; 
stx = dbx.createStatement();  
stx.executeUpdate(sqx); 
stx.close(); 
}
 
dbx.close();
 
} catch (Exception ex) {ex.printStackTrace();} 
 
 
 
 
} 
 
String change(String word){
String e;
e="'"+word+"'";
return e;    
}    
 
 
 
}
 
最終更新:2014年03月08日 15:02