public class SQLTranslator extends Object
apply(String)
method
is invoked when a new PreparedStatement
is about to be created from a SQL string.
Since the EPSG dataset is available primarily in MS-Access format,
the original SQL statements are formatted using a dialect specific to that particular database software.
If the actual EPSG dataset to query is hosted on another database product, then the SQL query needs to be
adapted to the target database dialect before to be executed.
'['
and ']'
) replaced by the quote character ('"'
) before to be sent to the database
driver. Furthermore table names may be different. So the following MS-Access query:
SELECT * FROM [Coordinate Reference System]
SELECT * FROM "Coordinate Reference System"
SELECT * FROM epsg_coordinatereferencesystem
(in the default schema)SELECT * FROM epsg.coordinatereferencesystem
(in the "epsg"
schema)SELECT * FROM epsg."Coordinate Reference System"
Element | Name in MS-Access database | Name in SQL scripts |
---|---|---|
Table | Alias | epsg_alias |
Table | Area | epsg_area |
Table | Coordinate Axis | epsg_coordinateaxis |
Table | Coordinate Axis Name | epsg_coordinateaxisname |
Table | Coordinate_Operation | epsg_coordoperation |
Table | Coordinate_Operation Method | epsg_coordoperationmethod |
Table | Coordinate_Operation Parameter | epsg_coordoperationparam |
Table | Coordinate_Operation Parameter Usage | epsg_coordoperationparamusage |
Table | Coordinate_Operation Parameter Value | epsg_coordoperationparamvalue |
Table | Coordinate_Operation Path | epsg_coordoperationpath |
Table | Coordinate Reference System | epsg_coordinatereferencesystem |
Table | Coordinate System | epsg_coordinatesystem |
Table | Datum | epsg_datum |
Table | Ellipsoid | epsg_ellipsoid |
Table | Naming System | epsg_namingsystem |
Table | Prime Meridian | epsg_primemeridian |
Table | Supersession | epsg_supersession |
Table | Unit of Measure | epsg_unitofmeasure |
Column | ORDER | coord_axis_order |
SQLTranslator
instances given to the EPSGFactory
constructor
shall be immutable and thread-safe.Defined in the sis-referencing
module
Constructor and Description |
---|
SQLTranslator(DatabaseMetaData md,
String catalog,
String schema)
Creates a new SQL translator for the database described by the given metadata.
|
Modifier and Type | Method and Description |
---|---|
String |
apply(String sql)
Adapts the given SQL statement from the original MS-Access dialect to the dialect of the target database.
|
String |
getCatalog()
Returns the catalog that contains the EPSG schema.
|
String |
getSchema()
Returns the schema that contains the EPSG tables.
|
public SQLTranslator(DatabaseMetaData md, String catalog, String schema) throws SQLException
If the given catalog or schema name is non-null, then the search for EPSG tables will be restricted to the catalog or schema of that name.
An empty string (""
) means to search for tables without catalog or schema.
A null
value means that the catalog or schema should not be used to narrow the search.
md
- information about the database.catalog
- the catalog where to look for EPSG schema, or null
if any.schema
- the schema where to look for EPSG tables, or null
if any.SQLException
- if an error occurred while querying the database metadata.public String getCatalog()
null
if the EPSG tables were not found or if the database
does not supports catalogs.null
.public String getSchema()
null
if the EPSG tables were not found or if the database
does not supports schemas.null
.public String apply(String sql)
sql
- the statement in MS-Access dialect.Copyright © 2010–2017 The Apache Software Foundation. All rights reserved.