我在javaFX / SQL中的库应用程序有点麻烦

时间:2018-05-08 13:36:26

标签: java mysql javafx phpmyadmin

我的LibraryApp有点问题,所以我的控制台告诉我错误: enter image description here 在PHPmyAdmin中我创建了几个表:

我将它们连接在借阅表中:

但是,当我想添加新的借给phpMYAdmin它完美的工作......

这里的代码应该添加到app和数据库new lend:

 @Override
public boolean addLend(int userId, int bookId, String returnDate) {
    try {

        PreparedStatement preparedStatementInsert = connector.getPreparedStatement(
                "INSERT INTO lend VALUES(?,?,?,?,?)");

        preparedStatementInsert.setInt(1, 0);
        preparedStatementInsert.setInt(2, userId);
        preparedStatementInsert.setInt(3, bookId);
        preparedStatementInsert.setString(4, returnDate);
        preparedStatementInsert.setTime(5, null);
        preparedStatementInsert.execute();
        preparedStatementInsert.close();
        return true;
    } catch (SQLException e) {
        e.printStackTrace();
    }
    return false;
}




private void tryAddLend() {
    int userId = (textCustomeridAddLend.getText().trim().length());
    int bookId = (textbookidAddLend.getText().trim().length());
    String returnDay = textReturnDayAddLend.getText();

    if (!checkAddLendData()) {
        return;
    }

    if (mainDao.addLend(userId, bookId, returnDay)) {

        Utils.createSimpleDialog("login", "", "added correctly");
    } else {
        Utils.createSimpleDialog("login", "", "error");
    }
    loadLends();
}

0 个答案:

没有答案