我正在创建银行管理系统,并且面临存款类别错误
SQLSyntaxErrorException:ORA-00933:SQL命令未正确结束
代码为:
try {
String a = t1.getText();
String b = t2.getText();
if (ae.getSource() == b1) {
if (t1.getText().equals("")) {
JOptionPane.showMessageDialog(null, "Please enter the Amount to you want to Deposit");
} else {
conn c1 = new conn();
ResultSet rs = c1.s.executeQuery(" select * from bank where pin = '" + b + "' ");
double balance = 0;
if (rs.next()) {
String pin = rs.getString("pin");
balance = rs.getDouble("balance");
double d = Double.parseDouble(a);
balance += d;
String q1 = "insert into bank values('" + pin + "','" + d + "',null,'" + balance + "')";
c1.s.executeUpdate(q1);
}
我已尝试解决此问题,但无法执行。问题是余额未插入银行表中,并且我正面临此错误,请问有人可以帮忙...
答案 0 :(得分:2)
尝试在Oracle数据库表中使用如下所示的插入语句,并确保bank表只有4列
String sql = "insert into bank values(?,?,?,?) ";
PreparedStatement pst = con.prepareStatement(sql);
pst.setString(1, pin);
pst.setString(2, d);
pst.setString(3, null);
pst.setString(4, balance);