アットウィキロゴ

p082708

package select;
 
public class pro {
 
int creditnumber;
String[] credit=new String[50];
String[] style=new String[50];
int[] strlong=new int[50];
 
int[] rank=new int[201];
String[][] data=new String[50000][10];  
int datanumber;
int number;
String[] v1=new String[500];
String[] v2=new String[500];
int[] year=new int[500];
int[] month=new int[500];
 
String[] subdata=new String[50000];
 
    public static void main(String[] args) {
        pro test=new pro();
    }
 
    pro(){
 
 
 
 
 
 
 
 
      String db,tab;
 
        db="car";
        tab="car";
 
 
        select sub=new select();
        sub.makedata(db,tab,"car12");
        number=sub.number;
        v1=sub.v;
        year=sub.year;
        month=sub.month;
 
 
   int s;     
 
 
        for(s=1;s<number+1;s++){    
        System.out.println(year[s]+"年"+month[s]+"月,"+v1[s]);
        }
 
 
 
 
 
 
 
    }
 
 
 
 
}
 
 
 
package select;
 
import java.sql.*; 
 
class select{ 
 
Connection dbx;   
Statement stx;   
String sqx; 
ResultSet  rsx; 
 
int key; 
String word;
int sx,number;
String[] v=new String[50000];
int[] year=new int[50000];
int[] month=new int[50000];
 
void makedata(String db,String tab,String  mak){ 
 
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();} 
 
sx=0;
try {   
stx = dbx.createStatement(); 
sqx="select * from "+tab+" where maker="+change(mak);   
rsx = stx.executeQuery(sqx); 
if (rsx != null) { 
while (rsx.next()) { 
sx=sx+1;
v[sx]= rsx.getString("value");
year[sx]= rsx.getInt("year");
month[sx]= rsx.getInt("month");
} 
} 
 
number=sx;
 
rsx.close(); 
stx.close(); 
dbx.close(); 
 
} catch (Exception ex) {ex.printStackTrace();} 
 
 
 
 
} 
 
String change(String word){
String e;
e="'"+word+"'";
return e;    
}    
 
 
 
}
 
最終更新:2015年08月27日 16:22