如果记录存在,我正在尝试更新值,否则将值插入数据库。但是,这是行不通的。我写了下面的代码。
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;
}