遍历查询
Connection connection = null;
PreparedStatement preparedStatement = null;
ComboPooledDataSource cSource = new ComboPooledDataSource();
try {
connection = cSource.getConnection();
preparedStatement = connection.prepareStatement("select * from u_p");
ResultSet b=preparedStatement.executeQuery();
while(b.next()) {
int id=b.getInt("id");
String username=b.getString("username");
String pw=b.getString("pw");
System.out.println(id+"----"+username+"----"+pw);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally {
try {
preparedStatement.close();
connection.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}