You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@metamodel.apache.org by Apache Wiki <wi...@apache.org> on 2016/08/08 03:45:23 UTC

[Metamodel Wiki] Update of "examples/JdbcDataContext" by KasperSorensen

Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Metamodel Wiki" for change notification.

The "examples/JdbcDataContext" page has been changed by KasperSorensen:
https://wiki.apache.org/metamodel/examples/JdbcDataContext

New page:
= JDBC DataContext =

The JDBC DataContext implementation, {{{JdbcDataContext}}}, provides access to relational JDBC databases via !MetaModel.

The class features:

 * Full MetaModel query pushdown capabilities.
 * Support for writes/updates too.
 * Rewriting queries to the individual SQL dialects available by automatically detecting what database is in use.
 * Construction of the DataContext directly or via a factory and properties.

== Instantiation via factory/properties ==

Here is an example properties set, useable to instantiate a JDBC DataContext:
{{{
type=jdbc
url=jdbc:mysql://localhost/sakila?defaultFetchSize=-2147483648
driver-class=com.mysql.jdbc.Driver
username=john
password=doe
catalog=
table-types=
}}}

Simply load these properties and pass them to MetaModel's {{{DataContextFactoryRegistryImpl}}} class:

{{{
Properties props = new Properties();
props.load(new FileInputStream("my_connection.properties");

DataContext dataContext = DataContextFactoryRegistryImpl.getDefaultInstance().createDataContext(props);
}}}

== Database compliancy ==

See DatabaseCompliancy for a list of JDBC databases that are known to work with !MetaModel via {{{JdbcDataContext}}}.