1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| public final void addGroupRecord(final Group gr) throws RemoteException,
SQLException, ClassNotFoundException {
int idGroupe = determineIdent("Groupe", "IdGroupe");
Class.forName("org.sqlite.JDBC");
con = DriverManager.getConnection("jdbc:sqlite:fcc-docs.db");
// create query
System.out.println("Groupe ID : " + idGroupe);
System.out.println("Groupe name : " + gr.getName());
System.out.println("Groupe owner : " + gr.getOwner().getIdent());
String query = "INSERT INTO Groupe VALUES(" + idGroupe + ",'"
+ gr.getName() + "'," + gr.getOwner().getIdent() + ");";
// Create a Statement object for sending SQL
// statements to the database.
//
Statement stmt = con.createStatement();
// execute the query
// throws RemoteException,
stmt.executeUpdate(query);
stmt.close();
con.close();
// groupe créé il faut créer les belong du groupe :
for (AbstractUser i : gr.getUsers()) {
addBelongRecord(i, gr);
}
System.out.println("Group Added");
} |