0

データベースに接続された 2 つのクライアントがあり、そのうちの 1 つが挿入クエリを実行すると、他のクライアントは挿入クエリを実行できなくなりますが、選択クエリは実行できます。両方のクライアントが挿入できる方法はありますか?

public int insertShiftHandover(String handoverDate, String unit, String shift, String handover) {
    String sql = "INSERT INTO ShiftHandover(unit,date,timePeriod,information) VALUES(?,?,?,?)";
    PreparedStatement pstmt = null;
    int success = 0;
    try {
        pstmt = conn.prepareStatement(sql);
        pstmt.setString(1, unit);
        pstmt.setString(2, handoverDate);
        pstmt.setString(3, shift);
        pstmt.setString(4, handover);
        pstmt.executeUpdate();
        success = 1;
    } catch (SQLException e) {
        System.out.println(e.getMessage());
    } finally {
        try {
            pstmt.close();
        } catch (SQLException e) {
            System.out.println(e.getMessage());
        }
    }
    return success;
}
4

0 に答える 0