【发布时间】:2014-05-05 21:37:23
【问题描述】:
我在 Java eclipse 中有一条错误消息。我在 MySql 中有一个数据库,它有列字符串 user_name、int id_time、int id_desk、int user_password。我想使用一行的列数据
public ArrayList showReservation(String user_name) throws SQLException{
// array list keeps the information
ArrayList<String> showReservation = new ArrayList<String>();
try{
String getReservationSql = "SELECT * FROM reservation "
+"WHERE user_name ='" + user_name + "';";
rs = stmt.executeQuery(getReservationSql);
// first element of the array list keeps user name
showReservation.add("" + rs.getString("user_name"));
// second element of the array list keeps id of the desk which is selected by user
showReservation.add("" + rs.getInt("id_time"));
// third element of the array list keeps id of the time interval which is selected by user
showReservation.add("" + rs.getInt("id_desk"));
// forth element of the array list keeps user's password which is generated automatically in a controller class
showReservation.add("" + rs.getInt("user_password"));
}catch (SQLException ex) {
System.out.println("Error: " + ex.getMessage());
}
return showReservation;
}
但是当我运行此代码时出现错误:在结果集开始之前。 我该如何解决这个错误? 谢谢
【问题讨论】: