Could someone look at my Statement stmt? is this error due to improper string creation?
Thanks
public String stmtCreateStudentTable =
"CREATE TABLE student ("
+ "stu_uid CHAR(11),"
+ "stu_password CHAR(11),"
+ "stu_lname CHAR(20),"
+ "stu_mname CHAR(20),"
+ "stu_fname CHAR(20),"
+ "stu_gender CHAR(1),"
+ "stu_age INT(3),"
+ "stu_start_date DATE,"
+ "stu_end_date DATE,"
+ "stu_address CHAR(20),"
+ "stu_state CHAR(2),"
+ "stu_zip INT(5),"
+ "stu_area_code INT(3),"
+ "stu_phone INT(11),"
+ "payee_uid CHAR(11),"
+ "PRIMARY KEY(stu_uid)"
+ ")";
public String[] schoolofdbTables = {
stmtCreateStudentTable,
stmtCreateInstructorTable,
stmtCreateAdminTable,
stmtCreatePayeeTable,
stmtCreateBookingTable,
stmtCreateInstrAvailableTable,
stmtCreateInstrumentTable,
stmtCreateLocationTable,
stmtCreatePaymentTable,
stmtCreatePayRollTable,
stmtCreateUserTable,
stmtCreateUserGroupTable,
stmtCreateUserGroupMappingTable,};
public boolean createTables(Connection conn) {
boolean bCreatedTables = false;
for (int i = 0; i < schoolofdbTables.length; i++) {
Statement stmt = null;
temp = null;
String temp = schoolofdbTables[i].trim();
System.out.println("table: " + temp);
try {
stmt = (Statement) conn.createStatement();
stmt.executeUpdate(temp);
stmt.close();
bCreatedTables = true;
} catch (SQLException ex) {
ex.printStackTrace();
}
}
return bCreatedTables;
}
run:
table: CREATE TABLE student (stu_uid CHAR(11),stu_password CHAR(11),stu_lname CHAR(20),stu_mname CHAR(20),stu_fname CHAR(20),stu_gender CHAR(1),stu_age INT(3),stu_start_date DATE,stu_end_date DATE,stu_address CHAR(20),stu_state CHAR(2),stu_zip INT(5),stu_area_code INT(3),stu_phone INT(11),payee_uid CHAR(11),PRIMARY KEY(stu_uid))
java.sql.SQLSyntaxErrorException: Syntax error: Encountered "(" at line 1, column 149.
at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown Source)