アットウィキロゴ

p0000p000

package db;
 
 
public class pro {
 
    int key; 
String word;
int sx,number;
String[] v=new String[500];
 String[] age=new String[500];
 
 
    public static void main(String[] args) {
        pro t=new pro();
    }
 
    pro(){
 
         select sub=new select();
        sub.makedata("wage","wage",26,"b1","s2","sc5","s1","c5");
        number=sub.number;
        v=sub.v;
 
        int s;
 
 
 
    for(s=1;s<number+1;s++){   
    System.out.println(v[s]);     
    }
 
 
 
    }
 
 
}
 
 
package db;
 
import java.sql.*; 
 
class select{ 
 
Connection dbx;   
Statement stx;   
String sqx; 
ResultSet  rsx; 
 
int key; 
String word;
int sx,number;
int[] year=new int[500];
String[] v=new String[500];
int[] month=new int[500];
 String[] age=new String[500];
 
void makedata(String db,String tab,int y1,String b1,String sex,String school,String size,String credit){ 
 
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 bus = "+change(b1)+" and year="+y1;
sqx=sqx+" and school="+change(school);  
sqx=sqx+" and sex="+change(sex);
sqx=sqx+" and credit="+change(credit);
sqx=sqx+" and size="+change(size);
 
rsx = stx.executeQuery(sqx); 
if (rsx != null) { 
while (rsx.next()) { 
sx=sx+1;
v[sx]= rsx.getString("value");
age[sx]=rsx.getString("age");
} 
} 
 
number=sx;
 
 
rsx.close(); 
stx.close(); 
dbx.close(); 
 
} catch (Exception ex) {ex.printStackTrace();} 
 
 
 
 
} 
 
String change(String word){
String e;
e="'"+word+"'";
return e;    
}    
 
 
 
}
 
最終更新:2016年06月12日 20:44