我正在使用 Netbeans 开发一个 GUI 桌面应用程序。我已经对总数进行了验证,但没有显示结果。请查看编码天气是否有一些更改或是否错误。当我执行它时,在第 3 列中显示错误并且没有结果
private void jButton15ActionPerformed(java.awt.event.ActionEvent evt) {
Connection con;
Statement stmt;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbc");
} catch (ClassNotFoundException ex) {
JOptionPane.showMessageDialog(null, ex);
}
try {
con= DriverManager.getConnection("Jdbc:Odbc:food");
stmt= con.createStatement();
String st= JcbSub.getSelectedItem().toString();
String qt= quantity.getText().toString();
String query;
Double u_p= (Double) jTable3.getValueAt(row, 1);
Integer qut= (Integer) jTable3.getValueAt(row, 2);
Double tot= u_p * qut; //product of column 1 & column 2
query="select i_price from food where i_name='"+JcbSub.getSelectedItem()+"'";
ResultSet rs= stmt.executeQuery(query);
while(rs.next()){
jTable3.setValueAt(st, row, 0);
jTable3.setValueAt(rs.getString("i_price"), row, 1);
jTable3.setValueAt(qt, row, 2);
jTable3.setValueAt(tot, row, 3); //result column
row ++;
}
} catch (SQLException ex) {
JOptionPane.showMessageDialog(null, ex);
}
}