我在Java應用程序的下拉列表中擁有所有表名。 我想要顯示JLabel表中的記錄數。 但我發現了以下錯誤java.sql.SQLSyntaxErrorException:ORA-00903:表名無效
java.sql.SQLSyntaxErrorException:ORA-00903:無效的表名
我已經試過這樣:
try {
String tableName = LoginFrame.userName + "." + this.ddlTableName.getSelectedItem().toString();
JOptionPane.showMessageDialog(null, tableName);
pst = (OraclePreparedStatement) con.prepareStatement("select count(*) as num from '" + tableName + "'");
rs = pst.executeQuery();
while (rs.next()) {
this.lblRecordStat.setText(rs.getString("num"));
}
} catch (SQLException ex) {
JOptionPane.showMessageDialog(null, ex);
System.out.println(ex);
}
控制檯打印表名並檢查它是否存在。 – Naruto