This section describes additional configuration which must be done to allow the commands to access SQL-compatible relational databases for reading or writing tables. If you don't need to talk to SQL-type databases, you can ignore the rest of this section. The steps described here are the standard ones for configuring JDBC (which sort-of stands for Java Database Connectivity), described in more detail on Sun's JDBC web page.
To use STILTS with SQL-compatible databases you must:
jdbc.drivers system property to the name of the
driver class as described in Section 2.5
These steps are all standard for use of the JDBC system. See SUN/252 for information about JDBC drivers known to work with STIL.
Here is an example of using tcopy to write the results of an SQL query on a table in a MySQL database as a VOTable:
tcopy -classpath /usr/local/jars/mysql-connector-java.jar \
-Djdbc.drivers=com.mysql.jdbc.Driver \
"jdbc:mysql://localhost/db1#SELECT id, ra, dec FROM gsc WHERE mag < 9" \
-ofmt votable gsc.vot
or invoking Java directly:
java -classpath stilts.jar:/usr/local/jars/mysql-connect-java.jar \
-Djdbc.drivers=com.mysql.jdbc.Driver \
uk.ac.starlink.ttools.TableCopy \
"jdbc:mysql://localhost/db1#SELECT id, ra, dec FROM gsc WHERE mag < 9" \
-ofmt votable gsc.vot
In the latter case you have to exercise some care to get the arguments
in the right order (see Section 2).
Alternatively, you can set some of this up beforehand to make the invocation easier. If you set your CLASSPATH environment variable to include the driver jar file (and the STILTS classes if you're invoking Java directly rather than using the scripts), and if you put the line
jdbc.drivers=com.mysql.jdbc.Driver
in the .starjava.properties file in your home directory,
then you could avoid having to give the -classpath and
-Djdbc.drivers flags respectively.