在Java程序中怎样动态的检查SQL语句是否正
1个回答
2017-09-19
展开全部
在Java程序中怎样动态的检查SQL语句是否正
String sql = "SELECT 角色 FROM userinfo WHERE 员工编号='A001' AND 密码='a'";
try {
ResultSet res = stmt.executeQuery(sql);
while (res.next()) { // 循环输出<a href="https://www.baidu.com/s?wd=%E7%BB%93%E6%9E%9C%E9%9B%86&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1Y4uHDkPhDduyDdrH0vn1Tz0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EnHf4PHm3nHc1PjfdnjckP1ckrf" target="_blank" class="baidu-highlight">结果集</a>
String role = res.getString("角色"); //这里可以根据字段名称得到该记录的角色的值
}
} catch (Exception e) {
e.printStackTrace();
}
String sql = "SELECT 角色 FROM userinfo WHERE 员工编号='A001' AND 密码='a'";
try {
ResultSet res = stmt.executeQuery(sql);
while (res.next()) { // 循环输出<a href="https://www.baidu.com/s?wd=%E7%BB%93%E6%9E%9C%E9%9B%86&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1Y4uHDkPhDduyDdrH0vn1Tz0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EnHf4PHm3nHc1PjfdnjckP1ckrf" target="_blank" class="baidu-highlight">结果集</a>
String role = res.getString("角色"); //这里可以根据字段名称得到该记录的角色的值
}
} catch (Exception e) {
e.printStackTrace();
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询