Package org.ivoa.dm.tapschema.utils
Class SchemaReader
java.lang.Object
org.ivoa.dm.tapschema.utils.SchemaReader
- All Implemented Interfaces:
AutoCloseable
Builds a TAP_SCHEMA model from JDBC metadata. Note that this fills the TAPSchema in a way that is suitable for
XML serialization, rather than that desirable for database storage.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classOptions controlling metadata harvesting. -
Constructor Summary
ConstructorsConstructorDescriptionSchemaReader(String jdbcUrl) Constructs a new SchemaReader with a JDBC URL.SchemaReader(String jdbcUrl, String user, String password) Contructs a new SchemaReader with a JDBC URL and credentials.SchemaReader(String jdbcUrl, Properties properties) Constructs a new SchemaReader with JDBC URL and properties.SchemaReader(Connection connection) constructs a new SchemaReader with an existing JDBC connection.SchemaReader(DataSource dataSource) Constructs a SchemaReader with a DataSource. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Translate the database metadata into a TAP_SCHEMA model.translate(SchemaReader.Options options) Translate the database metadata into a TAP_SCHEMA model.voidwriteSchemas(TapschemaModel model, OutputStream out)
-
Constructor Details
-
SchemaReader
Constructs a new SchemaReader with a JDBC URL. The connection will be owned and closed by this reader.- Parameters:
jdbcUrl- the JDBC URL to connect to the database. This should include any necessary credentials and parameters.- Throws:
SQLException
-
SchemaReader
Constructs a SchemaReader with a DataSource. The connection will be owned and closed by this reader.- Parameters:
dataSource- the configured dataSource.- Throws:
SQLException- if a problem with creating the database connection.
-
SchemaReader
Contructs a new SchemaReader with a JDBC URL and credentials. The connection will be owned and closed by this reader.- Parameters:
jdbcUrl- the JDBC URL to connect to the database. This should include any necessary parameters, but not credentials.user- the username for the database connection.password- the password for the database connection- Throws:
SQLException- if a problem with creating the database connection.
-
SchemaReader
Constructs a new SchemaReader with JDBC URL and properties.- Parameters:
jdbcUrl- the JDBC URL to connect to the database. This should include any necessary parameters, but not credentials.properties- the properties for the database connection, including credentials if necessary.- Throws:
SQLException- if a problem with creating the database connection.
-
SchemaReader
constructs a new SchemaReader with an existing JDBC connection. The connection will not be closed by this reader, and is the responsibility of the caller.- Parameters:
connection-
-
-
Method Details
-
translate
Translate the database metadata into a TAP_SCHEMA model. By default, system schemas are excluded and only tables and views are included. SeeSchemaReader.Optionsfor more control.- Returns:
- the translated metadata model.Note with schema, table and column names are qualified suitable for immediate XML serialization, rather than for database storage. See
XMLNormalizerfor normalizing the model for database storage. - Throws:
SQLException- if there is a problem reading the database metadata.
-
translate
Translate the database metadata into a TAP_SCHEMA model. By default, system schemas are excluded and only tables and views are included. SeeSchemaReader.Optionsfor more control.- Parameters:
options- translation options.- Returns:
- the translated metadata model.Note with schema, table and column names are qualified suitable for immediate XML serialization, rather than for database storage. See
XMLNormalizerfor normalizing the model for database storage. - Throws:
SQLException- if there is a problem reading the database metadata.
-
close
- Specified by:
closein interfaceAutoCloseable- Throws:
SQLException
-
writeSchemas
public void writeSchemas(TapschemaModel model, OutputStream out) throws IOException, jakarta.xml.bind.JAXBException - Throws:
IOExceptionjakarta.xml.bind.JAXBException
-