skip to Main Content

How can I check if accountNumber (non primary key) already exists in my database? – Mysql

String accountQuery = "insert into Account (accountNumber,currentBalance,type,personId) values (?,?,?,?);"; PreparedStatement accountPs = null; try { // These are my prepare Statements for my queries accountPs = conn.prepareStatement(accountQuery); // accountPs.setInt(1, personId.getPersonId()); accountPs.setInt(1, accountHolder.getAccountNumber()); accountPs.setDouble(2, accountHolder.getCurrentBalance()); accountPs.setString(3, accountHolder.getType()); accountPs.setInt(4, personId.getPersonId()); accountPs.executeUpdate(); accountPs.close();…

VIEW QUESTION
Back To Top
Search