当我在String类的matches()方法中使用这个正则表达式时,我收到了编译错误.谁知道我在做错了什么?谢谢
String email = "this@that.com";
System.out.println(email.matches("^(.+@.+\.\\w{2,4})$"));
Run Code Online (Sandbox Code Playgroud) 谁能看到我是如何错过这个 ResultSet 的?我收到以下错误customerID = rs.getInt(1):
public boolean addCustomer(Customer customer) {
String customerSQL = "INSERT INTO Customer (first_name, last_name)"
+ "VALUES (?, ?)";
String emailSQL = "INSERT INTO Email (customer_ID, email_address, primary_email)"
+ "VALUES (?,?,?)";
int customerID = 0;
try (Connection connection = getConnection();
PreparedStatement customerPs = connection.prepareStatement(
customerSQL, new String[] {"CUSTOMER_ID"});
//PreparedStatement idPs = connection.prepareStatement(idSQL);
//PreparedStatement emailPs = connection.prepareStatement(emailSQL)
) {
customerPs.setString(1, customer.getFirstName());
customerPs.setString(2, customer.getLastName());
customerPs.executeUpdate();
ResultSet rs = customerPs.getGeneratedKeys();
System.out.println("Result Set: " + rs.toString());
customerID = rs.getInt(1); …Run Code Online (Sandbox Code Playgroud)