所以我有这段代码,它应该为我提供一行的 id。
public int getIdSala(Connection conn, String t) {
try {
String query = "Select id_sala from sala where nume = ?";
PreparedStatement st = conn.prepareStatement(query);
st.setString(1, t);
ResultSet rs = st.executeQuery(query);
id = rs.getInt("Id_sala");
} catch (Exception e) {
System.err.println("Got an exception!");
System.err.println(e.getMessage());
}
return id;
}
我收到以下错误:
You have an error in your SQL syntax; check the manual that corresponds to your MySQLserver version for the right syntax to use near '?' at line 1
可能是什么问题呢?