import java.sql.*;
import java.io.*;
public class game0116{
int num;
String a[]=new String[1000];
public static void main (String args[]) {
new game0116();
}
game0116(){
Connection db = null; // DB接続オブジェクト
Statement st = null; // SQL文オブジェクト
ResultSet rs = null; // 問合せ結果オブジェクト
String url = "jdbc:derby:db;create=true"; // URL
String usr = ""; // ユーザ名
String pwd = ""; // パスワード
String bbc;
String abc;
int n;
inputdata();
abc=a[0];
for (n=1;n<num;n++){
abc=abc+a[n];
}
bbc="insert into hello5 values('";
bbc=bbc+abc;
bbc=bbc+"')";
try {
db = DriverManager.getConnection(url, usr, pwd);
st = db.createStatement();
st.executeUpdate("create table hello5 (item long varchar)");
st.executeUpdate(bbc);
rs = st.executeQuery("select * from hello5");
if (rs != null) {
while (rs.next()) {
String item = rs.getString("item");
System.out.println(item);
}
}
rs.close();
st.executeUpdate("drop table hello5");
st.close();
db.close();
} catch (Exception ex) {ex.printStackTrace();}
}
void inputdata(){
int n;
String s;
n=0;
try {
n=0;
FileReader fr = new FileReader("pp.txt");
BufferedReader br = new BufferedReader(fr);
while((s = br.readLine()) != null) {
a[n]=s;
n=n+1;
}
fr.close();
} catch (IOException e) {System.out.println(e);}
num=n;
}
}
最終更新:2011年03月24日 22:22