Search in sources :

Example 6 with H2Dialect

use of org.apache.ignite.cache.store.jdbc.dialect.H2Dialect in project ignite by apache.

the class CacheJdbcPojoStoreFactorySelfTest method cacheConfigurationH2Dialect.

/**
 * @return Cache configuration with store.
 */
private CacheConfiguration<Integer, String> cacheConfigurationH2Dialect() {
    CacheConfiguration<Integer, String> cfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME);
    CacheJdbcPojoStoreFactory<Integer, String> factory = new CacheJdbcPojoStoreFactory<>();
    factory.setDataSourceBean("simpleDataSource");
    factory.setDialect(new H2Dialect());
    cfg.setCacheStoreFactory(factory);
    return cfg;
}
Also used : H2Dialect(org.apache.ignite.cache.store.jdbc.dialect.H2Dialect) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 7 with H2Dialect

use of org.apache.ignite.cache.store.jdbc.dialect.H2Dialect in project ignite by apache.

the class CacheAbstractJdbcStore method resolveDialect.

/**
 * Perform dialect resolution.
 *
 * @return The resolved dialect.
 * @throws CacheException Indicates problems accessing the metadata.
 */
protected JdbcDialect resolveDialect() throws CacheException {
    Connection conn = null;
    String dbProductName = null;
    try {
        conn = openConnection(false);
        dbProductName = conn.getMetaData().getDatabaseProductName();
    } catch (SQLException e) {
        throw new CacheException("Failed access to metadata for detect database dialect.", e);
    } finally {
        U.closeQuiet(conn);
    }
    if ("H2".equals(dbProductName))
        return new H2Dialect();
    if ("MySQL".equals(dbProductName))
        return new MySQLDialect();
    if (dbProductName.startsWith("Microsoft SQL Server"))
        return new SQLServerDialect();
    if ("Oracle".equals(dbProductName))
        return new OracleDialect();
    if (dbProductName.startsWith("DB2/"))
        return new DB2Dialect();
    U.warn(log, "Failed to resolve dialect (BasicJdbcDialect will be used): " + dbProductName);
    return new BasicJdbcDialect();
}
Also used : MySQLDialect(org.apache.ignite.cache.store.jdbc.dialect.MySQLDialect) SQLServerDialect(org.apache.ignite.cache.store.jdbc.dialect.SQLServerDialect) H2Dialect(org.apache.ignite.cache.store.jdbc.dialect.H2Dialect) OracleDialect(org.apache.ignite.cache.store.jdbc.dialect.OracleDialect) SQLException(java.sql.SQLException) CacheException(javax.cache.CacheException) Connection(java.sql.Connection) BasicJdbcDialect(org.apache.ignite.cache.store.jdbc.dialect.BasicJdbcDialect) DB2Dialect(org.apache.ignite.cache.store.jdbc.dialect.DB2Dialect)

Aggregations

H2Dialect (org.apache.ignite.cache.store.jdbc.dialect.H2Dialect)7 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)4 Connection (java.sql.Connection)2 BinaryObject (org.apache.ignite.binary.BinaryObject)2 JdbcType (org.apache.ignite.cache.store.jdbc.JdbcType)2 JdbcTypeField (org.apache.ignite.cache.store.jdbc.JdbcTypeField)2 Person (org.apache.ignite.examples.model.Person)2 PreparedStatement (java.sql.PreparedStatement)1 SQLException (java.sql.SQLException)1 Timestamp (java.sql.Timestamp)1 UUID (java.util.UUID)1 CacheException (javax.cache.CacheException)1 CacheWriterException (javax.cache.integration.CacheWriterException)1 CacheJdbcPojoStoreFactory (org.apache.ignite.cache.store.jdbc.CacheJdbcPojoStoreFactory)1 BasicJdbcDialect (org.apache.ignite.cache.store.jdbc.dialect.BasicJdbcDialect)1 DB2Dialect (org.apache.ignite.cache.store.jdbc.dialect.DB2Dialect)1 MySQLDialect (org.apache.ignite.cache.store.jdbc.dialect.MySQLDialect)1 OracleDialect (org.apache.ignite.cache.store.jdbc.dialect.OracleDialect)1 SQLServerDialect (org.apache.ignite.cache.store.jdbc.dialect.SQLServerDialect)1 Organization (org.apache.ignite.cache.store.jdbc.model.Organization)1