我正在尝试编写 java 代码来访问具有列“customer_id”、“email”、“deliverable”和“create_date”的表“customer”
我有
Connection conn = DriverManager.getConnection(connectionUrl, connectionUser, connectionPassword);
Statement constat = conn.createStatement();
String query = "SELECT * FROM customer WHERE customer_id LIKE " + customerId;
ResultSet rtn = constat.executeQuery(query);
Customer cust = new Customer(rtn.getInt("customer_id"), rtn.getString("email"), rtn.getInt("deliverable"), rtn.getString("create_date"));
conn.close();
return cust;
我收到错误:
java.sql.SQLException:结果集开始之前
据我所知,我的错误在于我正在创建一个新的 Customer 对象,但我无法弄清楚我做错了什么。谁能给我一些帮助?谢谢!