Package io.deephaven.jdbc
Class JdbcToTableAdapter
java.lang.Object
io.deephaven.jdbc.JdbcToTableAdapter
The JdbcToTableAdapter class provides a simple interface to convert a Java Database Connectivity (JDBC)
ResultSet
to a Deephaven Table
.
To use, first create a result set using your provided JDBC driver of choice:
Connection connection = DriverManager.getConnection("jdbc:sqlite:/path/to/db.sqlite"); Statement statement = connection.createStatement(); ResultSet resultSet = statement.executeQuery("SELECT * FROM Invoice");Then convert the
ResultSet
to a Table
:
Table resultTable = JdbcToTableAdapter.readJdbc(resultSet);There are several options than can be set to change the behavior of the ingestion. Provide the customized options object to
readJdbc(ResultSet, ReadJdbcOptions, String...)
like this:
JdbcToTableAdapter.ReadJdbcOptions options = JdbcToTableAdapter.readJdbcOptions(); Table resultTable = JdbcToTableAdapter.readJdbc(resultSet, options);There are many supported mappings from JDBC type to Deephaven type. The default can be overridden by specifying the desired result type in the options. For example, convert BigDecimal to double on 'MyCol' via
options.columnTargetType("MyCol", double.class)
.-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
String formatting styles for use when standardizing externally supplied column names.static class
Options applicable when reading JDBC data into a Deephaven in-memory table. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Table
readJdbc
(ResultSet rs, JdbcToTableAdapter.ReadJdbcOptions options, String... origColumnNames) Returns a table that was populated from the provided result set.static Table
Returns a table that was populated from the provided result set.Returns a new options object that the user can use to customize a readJdbc operation.
-
Constructor Details
-
JdbcToTableAdapter
public JdbcToTableAdapter()
-
-
Method Details
-
readJdbcOptions
Returns a new options object that the user can use to customize a readJdbc operation.- Returns:
- a new ReadJdbcOptions object
-
readJdbc
Returns a table that was populated from the provided result set.- Parameters:
rs
- result set to read, its cursor should be before the first row to importorigColumnNames
- columns to include or all if none provided- Returns:
- a deephaven static table
- Throws:
SQLException
- if reading from the result set fails
-
readJdbc
public static Table readJdbc(ResultSet rs, JdbcToTableAdapter.ReadJdbcOptions options, String... origColumnNames) throws SQLException Returns a table that was populated from the provided result set.- Parameters:
rs
- result set to read, its cursor should be before the first row to importoptions
- options to change the way readJdbc behavesorigColumnNames
- columns to include or all if none provided- Returns:
- a deephaven static table
- Throws:
SQLException
- if reading from the result set fails
-