每日随笔

今天系统的学习了对数据库查看的语句,用途为查重

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;
}
}

原文地址:https://www.cnblogs.com/buxiang-Christina/p/14157852.html