TM2JDBC is a implementation of the TopicMaps API (TMAPI 2.0.2). It is a fast, production-grade Topic Maps Engine with a small dependency footprint. TM2JDBC uses a relational database to store its data, and is verified to operate with Apache Derby, MySQL, MSSQL Server and Oracle databases.
TM2JDBC is released in version 1.0.1. This release features some dependency updates and minor corrections of inconsistencies within the code, but is fully compatible to version 0.9.0.
- Updated TMAPI dependency to version 2.0.2 (the prior version already was compliant with TMAPI 2.0.2, but still referenced a snapshot as the final library was not released)
- OSGi support – The library now comes packaged as an OSGi-bundle, which allows it to be deployed to your OSGi container of choice. This has no side-effencts on non-OSGi projects
- Updated clazzes.org-dependencies to the current version
If you are using maven, you can use the new version by adding the following snippets to your
If you do not use maven, you can download the .jar files manually from our repository at http://maven.clazzes.org/org/clazzes/tm2jdbc.
Alternatively, you can check out the sources directly from our SVN Repository:
Setup and Usage Notes
TM2JDBC needs a relational database and the appropriate JDBC 4.0 compatible driver to function. However it does not have any direct dependencies to a specific JDBC connector. Instead, it expects a
javax.sql.DataSource to be set as a property (see below), which it will use to obtain database connections. Although the engine should function with any DataSource implementation, we strongly recommend to use the Apache Commons DBCP library. A rudimentary set-up for a
BasicDataSource can be found in the class
Providing a DataSource
To handle database connectivity, the TM2JDBC engine relies on a
javax.sql.DataSource to be set for the property
in the Factory (attempting to call
newTopicMapSystem() without the property being set causes an
IllegalStateException to be thrown. The property string can also be accessed directly via the Enum object
org.clazzes.tm2jdbc.voc.PropertyKey.CONNECTION_DATASOURCE. The most basic setup could look like this:
Running the DBSetup Utility in commandline
The engine provides a setup-utility to create the tables it needs in a provided database schema. This utility can either be run as a standalone java executable (in the command line, via a shell script etc.) or instanciated as a Java Object by your own code (see below). The class name is
org.clazzes.tm2jdbc.jdbc.setup.DBSetup. For testing and development, it may be useful to run the setup utility in commandline or the development evironment of your choice. The standard use-case is to set up the database schema, but you can also use it to drop all tables in the schema.
Making sure that the appropriate database drivers are added to the classpath, the accepts arguments like this:
Below is a listing of all argument flags and the default values:
|127.0.0.1||The hostname/address of your database server. Caution: When using Oracle database systems, the hostname is interpreted as a TNS name, which is resolved to an IP locally. Alternatively, you may also specify a string like|
|default port||If omitted, the default port for the specified database server is used|
|none||Alternatively to entering the hostname, port and schema name, you can supply the jdbc url directly.|
|none||You must enter a username and password|
|default driver class||If you want to use a different driver class than the default, you can specify the fully qualified classname using this flag. Make sure that the class is added to the classpath.|
|false||Produces a verbose output|
|false||Drops all tables in the schema, causes the utility to fail on errors|
|false||Drops all tables in the schema, ignoring any errors (Use to clean the schema if it was corrupted or not created completely)|
|false||Skip setting up the schema.|
Running the DBSetup Utility in Java
The database setup-utility also can be run in java. For this case it provides a constructor which takes a
javax.sql.DataSource, and provides the methods
setUpDB(boolean debug) and
dropAllTables(boolean supressErrors). It is recommended to use these instead of running the
main(String args) method with the appropriate arguments.
TMAPI provides an extensive suite of Testcases to assure compliancy, which is also included in the TM2JDBC package. As the original tests were not conceived for engines which are based on an RDBMS, the
tearDown() methods where modified to initialize and drop the database schema between every test. You are welcome to subject the engine to additional tests (we would especially appreciate you to share the results with us), and for this purpose TM2JDBC provides the utility class
org.clazzes.tm2jdbc.util.test.DataSourceProvider (depends on Apache commons DBCP).
It is recommended to use this utility in all test cases as follows: