package memo;
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];
void makedata(String db,String tab,String bus,String cr){
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 credit ="+change(cr)+" and "+"bus="+change(bus);
rsx = stx.executeQuery(sqx);
if (rsx != null) {
while (rsx.next()) {
sx=sx+1;
v[sx]= rsx.getString("value");
year[sx]=rsx.getInt("year");
}
}
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月16日 04:50