日期:2014-05-17 浏览次数:20801 次
public void validateid(String thename,String theid)
{
ResultSet rs = null;//rs接收的是数据库返回的结果
PreparedStatement psmt = null;
PreparedStatement psmt2 = null;
String sSql = "select cname from newsalary where identify=?";
String sSql2 ="update newsalary set message =? where identify =?";//定义sql语句
try {
psmt = connDB1.getConn().prepareStatement(sSql);
psmt.setString(1, theid);
rs = psmt.executeQuery();
while (rs != null && rs.next())
{
//System.out.println(rs.getString("cname"));
//实例化vo
psmt2 = connDB1.getConn().prepareStatement(sSql2);
if(rs.getString("cname").equals(thename))
{
psmt2.setString(1, "success!");
psmt2.setString(2, theid);
}
else
{
psmt2.setString(1, "name not match!");
psmt2.setString(2, theid);
}
psmt2.executeUpdate();
}
} catch (Exception e)
{
e.printStackTrace();
}finally
{
connDB1.commitConn();
connDB1.closeConn();
}
}