我尝试从组合框中填充文本字段,但收到以下错误消息,但不知道为什么?在youtube视频中有效
java.sql.SQLException: Column position '1' is out of range. The number of columns for this ResultSet is '0'. at .
at org.apache.derby.client.am.SQLExceptionFactory40.getSQLException(Unknown Source)
at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source)
at org.apache.derby.client.am.ColumnMetaData.getColumnType(Unknown Source)
at org.apache.derby.client.am.PreparedStatement.setString(Unknown Source)
try {
String s = jComboBoxKunde.getSelectedItem().toString();
String sql = "Select * from ROOT.KUNDE where NAME = '?'";
PreparedStatement pst = con.prepareStatement(sql);
pst.setString(1, s);
rst = pst.executeQuery(sql);
while (rst.next()) {
jTFauftraggeber.setText(rst.getString(1));
jTFtelefonnummer.setText(rst.getString(2));
jTFemail.setText(rst.getString(3));
}
} catch (SQLException ex) {
Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex);
}
我的rst
有什么问题吗?