import java.sql.*;
public class game0116{
public static void main (String args[]) {
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;
bbc="insert into hello5 values ('よう')";
try {
db = DriverManager.getConnection(url, usr, pwd);
st = db.createStatement();
st.executeUpdate("create table hello5 (item varchar(10000))");
st.executeUpdate("insert into hello5 values ('Hel wod')");
st.executeUpdate(bbc);
st.executeUpdate("insert into hello5 values ('AA')");
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();}
}
}
最終更新:2011年03月24日 21:33