I am trying to update a value if record exists else insert the values to database. However, that is not working. I have written the below code.
String sqlCheck = "Select * from [UAP].[dbo].[UAP_EMPLOYEE] where EMP_EMPLOYEE_ID = '"+empId+"' ";
PreparedStatement prpStatementCheck = conn.prepareStatement(sqlCheck);
prpStatementCheck.setString(1, EMP_EMPLOYEE_ID);
ResultSet rsCheck=prpStatementCheck.executeQuery();
String check=null;
while((rsCheck.next())
{
if(rsCheck.next()>0)
update statement;
else
Insert Statement;
}
As EMP_EMPLOYEE_ID field is an INTEGER type, use
setIntrather thansetString: