java -jar benow-launch.jar ProjectMaker --with repository
database directory within
the project root. The easy way has the db running in embedded mode, which is fine for single application use, but
if you wish to have multiple applications accessing the data or a different database server, please read the Preparing the Database Server section. Otherwise, if you're OK with the default JavaDB, you can proceed to Connecting
to the Repository.
If your data will be accessed by other applications, you'll want to run JavaDB in server mode.
etc/config/org.benow.repository.jdbc.xml in an editoretc/config/org.benow.repository.jdbc.xml in an editororg.benow.repository.jdbc.JDBCRepository.driver to have a value of com.mysql.jdbc.Driverorg.benow.repository.jdbc.JDBCRepository.url to use mysql and point to the database directory, ie jdbc:mysql:basicorg.benow.repository.jdbc.JDBCRepository.user to be a user capable of managing the databaseorg.benow.repository.jdbc.JDBCRepository.pass to be the password for the above useretc/config/org.benow.repository.jdbc.xml in an editororg.benow.repository.jdbc.JDBCRepository.driver to have a value of org.firebirdsql.jdbc.FBDriverorg.benow.repository.jdbc.JDBCRepository.url to use firebird and point to the database directory, ie jdbc:firebirdsql:/path/to/project/database/basic.gdborg.benow.repository.jdbc.JDBCRepository.pass to be the password for the sysda user for connecting to firebird, if required, ie masterkeyetc/config/org.benow.repository.jdbc.xml should be changed to only allow read by the application user, to protect the sysdba passworddatabase directory within the project root directory must be accessible to the firebird user (ie 'firebird' in un*x). If you see permissions errors, ensure that the directory permissions allow the firebird user to read and write the database directory.src/java/test/org/benow/repository/Tutorial.java
in an editor and looking at doConnect(). The code which connects to the repository is:
Transaction tx =null;
ObjectRepository repo=null;
ObjectRepositoryConnection conn=null;
try {
// get the repository
repo = RepositoryManager.getRepository();
// take a connection
conn = repo.takeConnection();
// take a transaction
tx = conn.getTransaction();
// the transaction can now be used.
log.info("The repository is ready to be used!");
// commit the transaction
tx.commitTransaction();
} catch (Throwable t) {
log.error("Error during run", t);
if (tx!=null)
tx.rollbackTransaction();
} finally {
// return the connection so that it may be reused.
repo.returnConnection(conn);
}
As you can see, it's quite simple. When the repository is taken, the database is created, as it does not exist. A connection to the repository is
taken, which can be used for working with the repository. From the connection, a transaction is taken, which group repository operations.
You can run the connection tester application using the included launcher from a terminal: sh bin/tutorial_repoitory.sh connect in
un*x (linux, solaris, osx) or bin\tutorial_repository.bat connect in windows. You will see the logging showing the creation of the database, and
should see 'The repository is ready to be used!'. This is only the basic connect to the repository and is actually more complicated than
typical use.
Now that you've made a connection to the repository, you'll probably want to use it. To create, store, retrieve and delete objects within the repository see the Using the Repository tutorial.