Ошибка говорит, что я не даю Cust_LastName
значение, если мои знания верны, но я пытаюсь с помощью кода ниже.java.sql.SQLException: Поле 'Cust_LastName' не имеет значения по умолчанию
Весь набор для одной новой строки в моей базе данных
// Accessing driver from JAR file
try {
Class.forName("com.mysql.jdbc.Driver");
// Creating a variable for the connection
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/schbank", "root", "s201431s");
// SQL statements to insert the information into the table
PreparedStatement statementFName = con.prepareStatement("insert into tblcustomer(Cust_FirstName)" + "values(?)");
PreparedStatement statementLName = con.prepareStatement("insert into tblcustomer(Cust_LastName)" + "values(?)");
PreparedStatement statementAddress = con.prepareStatement("insert into tblcustomer(Cust_Address)" + "values(?)");
PreparedStatement statementPhone = con.prepareStatement("insert into tblcustomer(Cust_PhoneNumber)" + "values(?)");
PreparedStatement statementSSN = con.prepareStatement("insert into tblcustomer(Cust_SSN)" + "values(?)");
PreparedStatement statementEmail = con.prepareStatement("insert into tblcustomer(Cust_Email)" + "values(?)");
PreparedStatement statementUsername = con.prepareStatement("insert into tblcustomer(Cust_Username)" + "values(?)");
PreparedStatement statementPassword = con.prepareStatement("insert into tblcustomer(Cust_Password)" + "values(?)");
// Sets the values
statementFName.setString(1, strFname);
statementLName.setString(1, strLname);
statementAddress.setString(1, strAddress);
statementPhone.setString(1, strPhone);
statementSSN.setString(1, strSSN);
statementEmail.setString(1, strEmail);
statementUsername.setString(1, strUserName);
statementPassword.setString(1, strPassword);
// Other code removed for brevity
} catch (SQLException ex) {
ex.printStackTrace(System.err);
}
, который объясняет многое, в первый раз, когда я начал использовать это, он был с двумя таблицами и одним полем в каждом, так что он работал, не совсем понял. – smoobies