アットウィキロゴ

JAVAがめ0113

import java.sql.*;
import java.io.*;  

public class game0117{
  
int num;
String a[]=new String[1000];

public static void main (String args[]) {
game0117 test=new game0117();
}

game0117(){
    Connection db = null;
    Statement  st = null;
    ResultSet  rs = null;  

    String url = "jdbc:derby:db;create=true";  
    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 hell values('";
bbc=bbc+abc;
bbc=bbc+"')";


    try {
      db = DriverManager.getConnection(url, usr, pwd);
      st = db.createStatement();
    
      st.executeUpdate(bbc);
      rs = st.executeQuery("select * from hell");
      if (rs != null) {
        while (rs.next()) {
          String article = rs.getString("article");
          System.out.println(article);
        }
      }
      rs.close();

      

      st.close();
      db.close();

    } catch (Exception ex) {ex.printStackTrace();}
  }


void inputdata(){
int n;
String s;
n=0;

try {
n=0;
FileReader fr = new FileReader("bon.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:42