// TODO code application logic herezd
String url = "jdbc:mysql://localhost:3306/stock_tangjiqian";
String username = "root";
String passwd = "38574638";
Class.forName("org.gjt.mm.mysql.Driver");
try {
connection = DriverManager.getConnection(url, username, passwd);
} catch (SQLException ex) {
// Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
ex.printStackTrace();
}
try {
statement = connection.createStatement();
} catch (SQLException ex) {
// Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
ex.printStackTrace();
}
try {
resultset = statement.executeQuery("select * from stock");
System.out.println(resultset.getRow());
} catch (SQLException ex) {
// Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
ex.printStackTrace();
}
System.out.println(resultset.getRow());
String url = "jdbc:mysql://localhost:3306/stock_tangjiqian";
String username = "root";
String passwd = "38574638";
Class.forName("org.gjt.mm.mysql.Driver");
try {
connection = DriverManager.getConnection(url, username, passwd);
} catch (SQLException ex) {
// Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
ex.printStackTrace();
}
try {
statement = connection.createStatement();
} catch (SQLException ex) {
// Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
ex.printStackTrace();
}
try {
resultset = statement.executeQuery("select * from stock");
System.out.println(resultset.getRow());
} catch (SQLException ex) {
// Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
ex.printStackTrace();
}
System.out.println(resultset.getRow());
{}
while(resultset.next())
{
//然后从resultset取得检索出来的数据即可
}