0

I have two clients connected to a database, once one of them has performed an insert query such as the one below the other one can never perform any insert queries but can still perform select queries. Any ideas how both clients can insert ?

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;
}
Arnaud
  • 17,229
  • 3
  • 31
  • 44

0 Answers0