Remote JDBC

Remote JDBC

  What's This?

This package provides a method for allowing a TINI to interact with databases using a set of classes that mimic JDBC. Typical JDBC drivers weigh in at 100k+ and typically require Java 1.2 or higher, which makes them a little heavy for the TINI. Also, the TINI API does not include the java.sql package. To allow TINI's to do things like data logging straight to a database, this package provides a server application that runs on a full sized computer as a type of proxy, and provides a set of classes for use on the TINI that mimic the Connection, Statement, ResultSet, etc. classes in java.sql. The client (TINI) executes calls to the server via XML-RPC, and the server forwards the calls to the database using the standard JDBC API.

On the TINI side, the change is almost invisible. As an example consider the following code snippet


  /* create client to proxy */
  RpcClient client = new RpcClient( http://192.168.1.51:5050 );
  client.setKeepAlive(true);
		
  /* prepare driver */
  DriverManager.setClient(client);
  if( !DriverManager.loadDriver( "org.gjt.mm.mysql.Driver" ) ) {
	throw new Exception( "No driver" );
  }

  /* execute query */	
  Connection conn = DriverManager.getConnection( 
  	"jdbc:mysql://192.168.1.54:3306/test", "root", "");
  Statement stmt = conn.createStatement();
  ResultSet rs = stmt.executeQuery( "select * from COFFEES" );
  ResultSetMetaData md = rs.getMetaData();
  n = md.getColumnCount();
  while (rs.next()) {
    for (int i = 1; i <= nC; i++) {
      if (i > 1) System.out.print(",  ");
      String columnValue = rs.getString(i);
      System.out.print(columnValue);
    }
    System.out.println("");	
  }

Other than the first four lines that initialize the XML-RPC connection and load the driver, this is exactly the JDBC sample code. A set of stub classes mimic the interface of DriverManager, Connection, and Statement but only pass along the parameters to the server that does all the heavy work of dealing with the database. The server then returns the response. The classes that mimic java.sql are currently less than 10k. A minimal program like that above compiled and built for the TINI is 13k!

  License

This software is subject to the Mozilla Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
 
Software distributed under the License is distributed on an "AS
IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
implied. See the License for the specific language governing
rights and limitations under the License.

The Original Code is "Hangar5 Remote JDBC".

The Initial Developer of the Original Code is James D. Rudnicki.  
Portions created by James D. Rudnicki are
Copyright (C) 2001.  All Rights Reserved.

The full license is available at www.mozilla.org .


Page created 04 May 04

Copyright 2004