gpt4 book ai didi

java - SQLITE_ERROR SQL 错误或丢失数据库(接近 "(": syntax error)

转载 作者:行者123 更新时间:2023-12-01 06:01:50 25 4
gpt4 key购买 nike

[SQLITE_ERROR] SQL error or missing database (near "(": syntax error)

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());
}

最佳答案

你失踪了;在最后。也许需要指定数据库。

SELECT MAX(right(id_kasir,3)) AS no FROM tbl_kasir;

尝试:

SELECT MAX(right(id_kasir,3)) AS no FROM {DBName}.tbl_kasir;

关于java - SQLITE_ERROR SQL 错误或丢失数据库(接近 "(": syntax error),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56209800/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com