morilib relations: a relational database


Top - Guide - Reference - Functions - Using JDBC - Download - 日本語

Using a JDBC driver

You should set these informations if you want to access morilib Relations via JDBC.
Driver name net.morilib.db.jdbc.RelationsDriver
URI jdbc:relations://a path of data/
The delimiter of the path should be the slash(/) in any OS. The last slash is required.

You should specify the path shown as follows.
UNIX/Mac OS X The path is identical to the acutual path.
e.g.) /usr/local/db → jdbc:relations:///usr/local/db/
Microsoft Windows The drive name should be specify as first directory.
e.g.) C:\usr\db → jdbc:relations:///c/usr/db/
User name will be ignored
Password will be ignored

The example is shown as follows.

	public void example1() {
		Connection c = null;
		PreparedStatement s = null;
		ResultSet r = null;
		int j;

		try {
			Class.forName("net.morilib.db.jdbc.RelationsDriver");
			c = DriverManager.getConnection("jdbc:relations://path/to/database/");
			s = c.prepareStatement("select NAME from idols");
			r = s.executeQuery();
			while(r.next()) {
				System.out.println(r.getString("NAME"));
			}
		} catch(Exception e) {
			throw new RuntimeException(e);
		} finally {
			try {
				if(r != null)  r.close();
				if(s != null)  s.close();
				if(c != null)  c.close();
			} catch(Exception e) {
				throw new RuntimeException(e);
			}
		}
	}


Yuichiro Moriguchi
yuichiro-moriguchi@nifty.com