今天系统的学习了对数据库查看的语句,用途为查重
public boolean chachong(String a) {
Connection connection = mql.getConnection();
PreparedStatement preparedStatement = null;
boolean temp = true;
try {
String sql = "select * from newclass where classname='" + a + "';";
preparedStatement = connection.prepareStatement(sql);
ResultSet rs = preparedStatement.executeQuery();
if (rs.next()) {
System.out.println("重复");
temp = false;
return temp;
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
// DBUtil.close(resultSet);
mql1.close(preparedStatement);
mql1.close(connection);
return temp;
}
}