class deleteByTerms
{
int index = 1;
String sql = null;
public boolean toChoose(Connection con, int chose, String var)
{
switch(chose)
{
case 1:
sql = "delete from worker_main where worker_id = ?";
break;
case 2:
sql = "delete from worker_main where worker_name = ?";
break;
}
int tag = delete(con, sql, index, var);
if (tag > 0)
return true;
else return false;
}
private static int delete(Connection con, String sql, int index, String var)
{
int result = 0;
PreparedStatement pre = null;
try
{
pre = con.prepareStatement(sql);
pre.setString(index, var);
result = pre.executeUpdate();
}
catch (SQLException e)
{
System.out.println("delete");
e.printStackTrace();
}
return result;
}
}