繁体   English   中英

SQLITE_ERROR SQL错误或数据库丢失(“(”附近:语法错误)

[英]SQLITE_ERROR SQL error or missing database (near “(”: syntax error)

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

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

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

尝试:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM