[SQLITE_ERROR] SQL错误或缺少数据库(“(“附近:语法错误)
try {
String sql = "SELECT MAX (right(id_kasir,3)) AS no FROM tbl_kasir";
st = connection.createStatement();
rs = st.executeQuery(sql);
while (rs.next()) {
if (rs.first() == false) {
txtidkasir.setText("KS001");
} else {
rs.last();
int auto_id = rs.getInt(1) + 1;
String no = String.valueOf(auto_id);
int noLong = no.length();
for (int a = 0; a < 3 - noLong; a++) {
no = "0" + no;
}
txtidkasir.setText("KS" + no);
}
}
} catch (Exception e) {
System.out.println("Error" + e.getMessage());
}
答案 0 :(得分:-1)
您失踪了;在末尾。也许需要指定数据库。
选择MAX(right(id_kasir,3))AS no FROM tbl_kasir;
尝试:
SELECT MAX(right(id_kasir,3))AS no FROM {DBName} .tbl_kasir;