...
Code Block | ||
---|---|---|
| ||
Connection conn = DriverManager.getConnection(...); DataContext dataContext = new JdbcDataContext(conn); |
Creating from properties - JdbcDataContextFactory
If you wish to construct your JDBC DataContext from properties, this is also possible. For instance:
Code Block | ||
---|---|---|
| ||
final DataContextPropertiesImpl properties = new DataContextPropertiesImpl(); properties.put("type", "jdbc"); properties.put("url", "jdbc:postgresql://localhost:5432/mydb"); DataContext dataContext = DataContextFactoryRegistryImpl.getDefaultInstance().createDataContext(properties); |
The relevant properties for this type of instantiation are:
Property | Example value | Required | Description |
---|---|---|---|
|
| Must be set to 'jdbc' or else another type of DataContext will be constructed. | |
|
| The JDBC URL to use. | |
|
| The JDBC driver class name. | |
|
| The username to use when connecting. | |
|
| The password to use when connecting. | |
|
| A comma-separated list of table types to include in JDBC metadata discovery. | |
|
| The JDBC 'catalog' value |
Additional behaviour configuration
The module contains a few features that are specific to the JDBC interactions. These are all configured as Java system properties.
System property | Default value | Description |
---|---|---|
|
| Whether or not to automatically convert CLOBs into String and BLOBs into byte[] . |
|
| Whether or not using the JDBC batch API should be allowed. Set to "true" or "false" to override the default dynamic behavior. |
|
| The maximum number of open prepared statements to keep in a pool for the compiled queries. |
|
| The minimum idle timeout before a prepared statement is marked as evictable. |
|
| The time between eviction runs in the compiled queries pool. |