您的SQL语法有错误,如何解决?

时间:2015-04-13 04:50:58

标签: java mysql

我在从MYSQL显示数据的过程中遇到了这个问题

这是我的代码

       int row = 0;

       String sql = "SELECT * FROM db_transection INNER JOIN db_book ON  db_book.book_id = db_transection.book_id WHERE member_id = " + tx_member_id.getText() + " AND tran_type = 'borrow'";

        ResultSet rs = con.createStatement().executeQuery(sql);
        while (rs.next()) {
            modelTran.addRow(new Object[0]);
            modelTran.setValueAt(rs.getInt("tran_id"), row, 0);
            modelTran.setValueAt(rs.getInt("book_id"), row, 1);
            modelTran.setValueAt(rs.getString("book_name"), row, 2);
            modelTran.setValueAt(rs.getInt("member_id"), row, 3);
            row++;
        }
        table_tranborrow.setModel(modelTran);

    } catch (Exception e) {
        e.printStackTrace();
    }

它会抛出错误 -

  

您的SQL语法有错误;检查手册   对应于您的MySQL服务器版本,以便使用正确的语法   在第1行'AND tran_type ='借用'附近

如何解决?

0 个答案:

没有答案