データベースに接続するための元のコード

class.forName ("com.mysql.jdbe.Driver");
Connection con = DriverManager.getConnection("jdbe:mysql://localhost:3306/db1","root","root");
Statement stat = con.createstatement ()
String sql = "SELECT FROM product";
ResultSet rs = stat.executeQuery(sql);
while(rs.next ()){
    System.out.println(rs.getInt ("id"));
}
con.close ()
stat.close();
rs.close();

おすすめ

転載: blog.csdn.net/guoweiting/article/details/128595283