You can view the result of an SQL query on a relational database as
a table. This can be done either by passing the query string directly to
a JDBCHandler
or
by passing it to the generic
StarTableFactory.makeStarTable
method (any string starting 'jdbc:' in the latter case is assumed to
be an SQL query string).
The form of this query string is as follows:
jdbc:<driver-specific-url>#<sql-query>The exact form is dependent on the JDBC driver which is installed. Here is an example for MySQL:
jdbc:mysql://localhost/astro1?user=mbt#SELECT ra, dec FROM swaa WHERE vmag<18If the username and/or password are required for the query but are not specified in the query string, they will be prompted for.
Note that the StarTable does not represent the JDBC table itself,
but a query on table. You can get a StarTable representing the
whole JDBC table with a query like SELECT * from table-name
,
but this may be expensive for large tables.