Search in sources :

Example 6 with Platform

use of io.requery.sql.Platform in project requery by requery.

the class PlatformFromConnection method apply.

@Override
public Platform apply(Connection connection) {
    Platform platform;
    String product;
    try {
        product = connection.getMetaData().getDatabaseProductName();
    } catch (SQLException e) {
        throw new PersistenceException(e);
    }
    if (product.contains("PostgreSQL")) {
        platform = new PostgresSQL();
    } else if (product.contains("SQLite")) {
        platform = new SQLite();
    } else if (product.contains("MySQL")) {
        platform = new MySQL();
    } else if (product.contains("H2")) {
        platform = new H2();
    } else if (product.contains("HSQL Database Engine")) {
        platform = new HSQL();
    } else if (product.contains("Apache Derby")) {
        platform = new Derby();
    } else if (product.contains("Oracle")) {
        platform = new Oracle();
    } else if (product.contains("Microsoft SQL Server")) {
        platform = new SQLServer();
    } else {
        platform = new Generic();
    }
    return platform;
}
Also used : Platform(io.requery.sql.Platform) SQLException(java.sql.SQLException) PersistenceException(io.requery.PersistenceException)

Aggregations

Platform (io.requery.sql.Platform)6 EntityModel (io.requery.meta.EntityModel)5 Configuration (io.requery.sql.Configuration)5 ConfigurationBuilder (io.requery.sql.ConfigurationBuilder)5 SchemaModifier (io.requery.sql.SchemaModifier)5 HSQL (io.requery.sql.platform.HSQL)5 CommonDataSource (javax.sql.CommonDataSource)5 Before (org.junit.Before)5 EntityDataStore (io.requery.sql.EntityDataStore)4 EntityCacheBuilder (io.requery.cache.EntityCacheBuilder)3 CacheManager (javax.cache.CacheManager)3 CachingProvider (javax.cache.spi.CachingProvider)3 PersistenceException (io.requery.PersistenceException)1 TransactionIsolation (io.requery.TransactionIsolation)1 TransactionListener (io.requery.TransactionListener)1 EmptyEntityCache (io.requery.cache.EmptyEntityCache)1 Supplier (io.requery.util.function.Supplier)1 SQLException (java.sql.SQLException)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1