Child pages
  • TopicMap Engine Home

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Confluence.Clazzes.org moved to Clazzes.atlassian.net

This page has been moved to the Atlassian cloud

This page can now be found at: https://clazzes.atlassian.net/wiki/spaces/TME

---

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.

...

If you are using maven, you can use the new version by adding the following snippets to your pom.xml file:


 

No Format
<dependency>
  <groupId>org.clazzes</groupId>
  <artifactId>tm2jdbc</artifactId>
  <version>1.0.1</version>
</dependency>

 
...
 
<repository> 
  <id>org.clazzes</id>
  <name>Clazzes.org repository.</name>
  <url>http://maven.clazzes.org</url>
</repository>
 


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:

...

To handle database connectivity, the TM2JDBC engine relies on ajavax.sql.DataSource to be set for the property http://psi.clazzes.org/topicmaps/db-connection/datatsource in the Factory (attempting to call newTopicMapSystem() without the property being set causes anIllegalStateException to be thrown. The property string can also be accessed directly via the Enum objectorg.clazzes.tm2jdbc.voc.PropertyKey.CONNECTION_DATASOURCE. The most basic setup could look like this:

...


Code Block
languagejava
BasicDataSource datasource = new BasicDataSource();
datasource.setDefaultAutoCommit(false);

datasource.setInitialSize(4);
datasource.setMinIdle(1);
datasource.setMaxIdle(8);
datasource.setMaxActive(8);
datasource.setMaxWait(3000);

datasource.setDriverClassName(driver);

datasource.setPassword(password);
datasource.setUsername(user);
datasource.setUrl(url);

TopicMapSystemFactory factory = TopicMapSystemFactory.newInstance();
factory.setProperty(PropertyKey.CONNECTION_DATASOURCE.getURI(), dsProvider.getDataSource());

TopicMapSystem system = factory.newTopicMapSystem();
 


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:


 

No Format
DBSetup {derby|mssql|mysql|oracle} {{ [-h <HOSTNAME>] [-t <PORT>] [-n <SCHEMA NAME>] } | {--url <DATABASE-URL>}} -u <USER> -p <PASSWORD> [-d <DRIVER-CLASSNAME> ] [--debug] [--drop|--force-drop] [--nosetup]
 


Below is a listing of all argument flags and the default values:

FlagDefault ValueDescription
-h127.0.0.1The 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<IP-HOST>/<SID>
-tdefault portIf omitted, the default port for the specified database server is used
-ntopicmaps
 

--urlnoneAlternatively to entering the hostname, port and schema name, you can supply the jdbc url directly.
-unoneYou must enter a username and password
-pnone
 

-ddefault driver classIf 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.
--debugfalseProduces a verbose output
--dropfalseDrops all tables in the schema, causes the utility to fail on errors
--force-dropfalseDrops all tables in the schema, ignoring any errors (Use to clean the schema if it was corrupted or not created completely)
--nosetupfalseSkip setting up the schema.

Running the DBSetup Utility in Java

...

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 setUp() and 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 classorg.clazzes.tm2jdbc.util.test.DataSourceProvider (depends on Apache commons DBCP).
It is recommended to use this utility in all test cases as follows:

...


Code Block
languagejava
protected DataSourceProvider dsProvider;

protected void setUp() throws Exception {
	super.setUp();
	if (dsProvider == null) {
		dsProvider = DataSourceProvider.getProvider();
		dsProvider.setUpDB();
	
		//set up factory etc. here ...
		factory.setProperty(PropertyKey.CONNECTION_DATASOURCE.getURI(), dsProvider.getDataSource());
		//...
	}
}

protected void tearDown() throws Exception {
	dsProvider.dropDB();
}

Source code and issue tracker

Subversion: http://svn.clazzes.org/svn/topicmaps

Jira: TME