Hello.
Is there someone who might be able to show me how to adjust a insert for a prepared statement sent to a derby embedded db?
run:
driver name from xml: org.apache.derby.jdbc.EmbeddedDriver
in bCreatedTables:
created table: createAdminTable
created table: createPayeeTable
created table: createStudentTable
created table: createInstructorTable
created table: createBookingTable
created table: createInstrAvailableTable
created table: createInstrumentTable
created table: createLocationTable
created table: createPaymentTable
created table: createPayrollTable
created table: createUserTable
created table: createUserGroupTable
created table: createUserGroupMappingTable
in bInsertedTables:
Error at : insertAdminTable
INSERT INTO admin (admin_uid,admin_fname,admin_password) VALUES ('ag','Garth','a')
INSERT INTO admin (admin_uid,admin_fname,admin_password) VALUES ('aw','Wayne','a')
Error at : insertPayeeTable
INSERT INTO payee (payee_uid,payee_fname,payee_password) VALUES ('ps','Suzies mom','p')
INSERT INTO payee
(payee_uid,payee_fname,payee_password) VALUES ('pj','Johnie dad','p')
Error at : insertStudentTable
INSERT INTO student (stu_uid,stu_fname,stu_password) VALUES ('sj','Johnny','s')
INSERT INTO student (stu_uid,stu_fname,stu_password) VALUES ('ss','Suzie','s')
Error at : insertInstructorTable
INSERT INTO instructor
(instr_uid,instr_fname,instr_password) VALUES ('ij','Johanne','i')
INSERT INTO instructor
(instr_uid,instr_fname,instr_password) VALUES ('im','Mozart','i')
Error at : insertBookingTable
Error at : insertInstrAvailableTable
Error at : insertInstrumentTable
Error at : insertLocationTable
Error at : insertPaymentTable
INSERT INTO payment (pymt_method) VALUES ('cash')
INSERT INTO payment (pymt_method) VALUES ('credit')
Error at : insertPayrollTable
Error at : insertUserTable
INSERT INTO user VALUES
('aw','a'),
('sj','s'),
('im','i'),
('ps','p')
Error at : insertUserGroupTable
INSERT INTO `usergroup` VALUES ('adm','admin'),('std','student'),('instr','instructor'),('pye','payee')
Error at : insertUserGroupMappingTable
INSERT INTO `usergroup_mapping` VALUES ('aw','adm'),('sj','std'),('im','instr'),('ps','pye'),('ag','adm')
method to insert
public boolean bInsertedTables(Connection conn) throws FileNotFoundException, IOException {
conn = getConn();
System.out.println("in bInsertedTables:");
boolean bInsertedTables = false;
for (int i = 0; i < insertSchoolofdbTables.length; i++) {
PreparedStatement ps = null;
String query = "";
String badInsert = "";
try {
badInsert = insertSchoolofdbTables[i].trim();
query = ModelUtils.getXMLResource(insertSchoolofdbTables[i].trim());
ps = (PreparedStatement) conn.prepareStatement(query);
ps.execute();
bInsertedTables = true;
ps.close();
System.out.println("created table: " + insertSchoolofdbTables[i]);
} catch (SQLException ex) {
System.out.println("Error at : " + badInsert);
String value = dbProperties.getProperty(badInsert);
System.out.println(value);
//ex.printStackTrace();
}
}
return bInsertedTables;
}