我有下面的数据框,如图所示。如何将图例中显示的值限制为仅前三个?换句话说,我希望它只显示" A"," B"和" C"。
public void addData(User data) {
Connection conn = null;
try {
conn = dataSource.getConnection();
if (conn == null || conn.isClosed()) {
throw new RuntimeException("Could not open connection");
}
String query="INSERT INTO USER "
+ "(ID, NAME, PASSWORD, ENABLED, REQUIRE_RESET)"
+ "VALUES (?, ?, ?, ?, ?);";
PreparedStatement ps = conn.prepareStatement(query);
// "ID" column is INTEGER, and partition field in UserData is int.
ps.setString(1, data.getId());
ps.setString(2, data.getName());
ps.setString(3, data.getPassword());
// "ENABLED" column is INTEGER, and enabled field in UserData is boolean.
ps.setInt(4, data.isEnabled()? 1:0);
ps.setString(5, data.isRequireReset()?"Y":"N");
if (ps.executeUpdate() < 1) {
throw new RuntimeException("Could not save User, executeUpdate() returned a value < 1");
}
} Catch (SQLException e) {
throw new DataLayerException("Could not save the User Data.", e);
} finally {
if (conn != null) {
try {
conn.close();
} catch (SQLException e) {
}
}
}
}