アットウィキロゴ

db

package h3;
 
import hsql.*;
 
public class pro {
 
public int[] strlong=new int[100];
public String[] credit=new String[100];
public String[] type=new String[100];
public int creditnumber,datanumber;
  String[][] data=new String[500000][20];  
int s;
 
    public static void main(String[] args) {
        pro test=new pro();
    }
pro(){
 
    int key;
 
    key=100;
 
 
    if(key>50){
 
droptable sub5=new droptable();
sub5.makedata("a","a1");
 
    }
 
 
    type[1]="VARCHAR";
    type[2]="INTEGER";
    creditnumber=2;
    credit[1]="a";
    credit[2]="b";
 
    table sub=new table();
    sub.type=type;
    sub.credit=credit;
    sub.creditnumber=creditnumber;
    sub.makedata("a","a1");
 
 
 
checktable sub2=new checktable();
sub2.makedata("a","a1");
type=sub2.type;
credit=sub2.credit;
creditnumber=sub2.creditnumber;
 
 
 
 
datanumber=50;
for(s=1;s<100;s++){
data[s][1]="ADC";
data[s][2]=""+4;
}
 
insert sub3=new insert();
sub3.type=type;
sub3.credit=credit;
sub3.creditnumber=creditnumber;
sub3.datanumber=datanumber;
sub3.data=data;
sub3.makedata("a","a1");
 
 
select sub4=new select();
sub4.makedata("a","a1","ADC");
 
 
 
 
 
}
}
 
 
 
 
package h3;
 
import java.io.*; 
import java.net.*;   
import java.sql.*; 
 
class select{ 
 
void makedata(String dbx,String tbx,String word){ 
 
Connection db = null; 
Statement  st = null;   
ResultSet  rs = null;   
 
String url = "jdbc:h2:"+dbx+";create=true";   
String usr = "";   
String pwd = ""; 
 
 
try { 
      db = DriverManager.getConnection(url, usr, pwd); 
      st = db.createStatement(); 
 
      String str1;
 
 
      str1="select * from "+tbx+" where a like "+change(word);
 
       System.out.println(str1);
 
      rs = st.executeQuery(str1); 
      if (rs != null) { 
        while (rs.next()) { 
          int item = rs.getInt("b"); 
          System.out.println(item); 
        } 
      } 
      rs.close(); 
      st.close(); 
      db.close(); 
 
    } catch (Exception ex) {ex.printStackTrace();}   
 
 
 
} 
String change(String st){
 
return "'"+st+"'";    
}
}
 
最終更新:2014年04月28日 23:11