【发布时间】:2014-08-03 13:53:16
【问题描述】:
我的数据库中有一个表,它有两列 id 和 name 。我为这两列的获取和设置值编写了一个类。
我的课程名称是:
public String getCourseName(int id) throws SQLException {
String SQL = "select * from courses where id ="+id;
Connection con = c.getCon();
Statement statement = con.createStatement();
ResultSet res = statement.executeQuery(SQL);
String nm = res.getString("name");
return nm;
}
当我运行这个函数时,它显示错误 http 状态 500 异常:
javax.servlet.ServletException: java.sql.SQLException: Before start of result set
【问题讨论】: