import java.sql.*;
public class hello4{
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 = ""; // パスワード
try {
db = DriverManager.getConnection(url, usr, pwd);
st = db.createStatement();
rs = st.executeQuery("select * from hello4");
if (rs != null) {
while (rs.next()) {
String item = rs.getString("item");
System.out.println(item);
}
}
rs.close();
st.close();
db.close();
} catch (Exception ex) {ex.printStackTrace();}
}
}
最終更新:2011年03月24日 19:01