ResultSet rset = null;
try {
/**
* Enter SQL Query
*/
rset = stmt.executeQuery("select deptid, deptname from dept");
/**
* Process SQL Query and print out
*/
while(rset.next()) {
int deptid = rset.getInt("deptid");
String deptname = rset.getString(2);
System.out.println(deptid +", "+deptname);
}
} catch (SQLException e1) {
e1.printStackTrace();
}
沒有留言:
張貼留言