General information about individual databases
Individual databases are used in todo4teams to store solution-related structured data, such as the collection of spam sender addresses, customer data, etc.
Access to this data is extremely fast and you can determine the structure of the tables yourself. The Apache Derby database used supports indices, referential integrity and all other features that you would expect from an SQL database.
To be able to use an individual database in todo4teams scripts, please follow the steps below:
- Start todo4teams with the role "Administrator" or "Super Administrator"
- Open the "Server Settings" section
- Click on "Create" to save a new server setting
- Enter the name of the new database as the key - here e.g. MyCustomDB:
- In the 'Value' area you must enter the name of the database and the directory in which the database is to be saved (see example): Please note that the database directory - here: /home/databases - must exist and be writable for the executing user of the Tomcat application server!
- Then in the (server-side) scripts in todo4teams use the new database as follows: The database name to use here is the one you entered as the "Key" above.
- Use the database like any other JDBC database in Java. This is a Derby database. More Derby-specific information can be found here: https://db.apache.org/derby/docs/10.0/manuals/reference/sqlj02.html
var con = helper.getCustomDB("MyCustomDB");
ar stmt = con.prepareStatement("INSERT INTO MyTable (myId, taskId, creationDate) VALUES (?,?, CURRENT_TIMESTAMP)");
stmt.setString(1, sfFormId);
stmt.setString(2, taskId);
try{
stmt.executeUpdate();
if (!con.getAutoCommit()){
c.commit();
}
return true;
}
catch(de){
// collision!
println(de.getMessage());
return false;
}
finally{
stmt.close();
}
ar stmt = con.prepareStatement("INSERT INTO MyTable (myId, taskId, creationDate) VALUES (?,?, CURRENT_TIMESTAMP)");
stmt.setString(1, sfFormId);
stmt.setString(2, taskId);
try{
stmt.executeUpdate();
if (!con.getAutoCommit()){
c.commit();
}
return true;
}
catch(de){
// collision!
println(de.getMessage());
return false;
}
finally{
stmt.close();
}