Hey guys,
I cant program my project because this stupid issue has risen out of no where. For some reason the preparedstatement executes but no changes are made in the db. I am using this as a part of a web app i am developing in eclipse but i decided to put this into main and debug this as it wasnt working but its still causing a headache after countless hours on end. Theres no problem with the db connection as theres a similar query that working fine. I have just about tried everything, any help would be appreciated.
public class Main { static PreparedStatement preparedStatementinsert ; public static void main(String[] args) { try { Class.forName(DBConstants.DB_DRIVER); } catch (ClassNotFoundException cfe) { System.out.println("The JDBC drive loading failed."); cfe.printStackTrace(); } try { dbCon = DriverManager.getConnection(DBConstants.DB_NAME); } catch (SQLException se) { SQLExcept.handleException(se); } dbCon=ConnectionManager.getConnection(); String MyQuery= "INSERT INTO LoggedInUsers(Email,SessionID) VALUES(?,?)"; String email = "sdas"; String Session = "adsadsads"; try{ preparedStatementinsert= dbCon.prepareStatement(MyQuery); preparedStatementinsert.setString(1, "asdddddddddddddddddddddddddemail"); preparedStatementinsert.setString(2, "Sessioasdddddddddddddddddddddn"); int click=preparedStatementinsert.executeUpdate(); System.out.println(click); }catch(SQLException e){ //this.success=false; SQLExcept.handleException(e); e.printStackTrace(); } } }
Variable click keeps on returning 1 every time even if theres a tuple in the relation. Also there has been a few instances(3 out of about a 1000) that the tuple has miraculously appeared in the relation. Doesn't make sense. Also , there are no problems with committing as i have never changed it and its always been at default which is true.