Search in sources :

Example 1 with DriverConnectionFactory

use of com.facebook.presto.plugin.jdbc.DriverConnectionFactory in project presto by prestodb.

the class MySqlClient method connectionFactory.

private static ConnectionFactory connectionFactory(BaseJdbcConfig config, MySqlConfig mySqlConfig) throws SQLException {
    Properties connectionProperties = basicConnectionProperties(config);
    connectionProperties.setProperty("useInformationSchema", "true");
    connectionProperties.setProperty("nullCatalogMeansCurrent", "false");
    connectionProperties.setProperty("useUnicode", "true");
    connectionProperties.setProperty("characterEncoding", "utf8");
    connectionProperties.setProperty("tinyInt1isBit", "false");
    if (mySqlConfig.isAutoReconnect()) {
        connectionProperties.setProperty("autoReconnect", String.valueOf(mySqlConfig.isAutoReconnect()));
        connectionProperties.setProperty("maxReconnects", String.valueOf(mySqlConfig.getMaxReconnects()));
    }
    if (mySqlConfig.getConnectionTimeout() != null) {
        connectionProperties.setProperty("connectTimeout", String.valueOf(mySqlConfig.getConnectionTimeout().toMillis()));
    }
    return new DriverConnectionFactory(new Driver(), config.getConnectionUrl(), Optional.ofNullable(config.getUserCredentialName()), Optional.ofNullable(config.getPasswordCredentialName()), connectionProperties);
}
Also used : DriverConnectionFactory(com.facebook.presto.plugin.jdbc.DriverConnectionFactory) Driver(com.mysql.jdbc.Driver) Properties(java.util.Properties) DriverConnectionFactory.basicConnectionProperties(com.facebook.presto.plugin.jdbc.DriverConnectionFactory.basicConnectionProperties)

Example 2 with DriverConnectionFactory

use of com.facebook.presto.plugin.jdbc.DriverConnectionFactory in project presto by prestodb.

the class OracleClientModule method connectionFactory.

@Provides
@Singleton
public static ConnectionFactory connectionFactory(BaseJdbcConfig config, OracleConfig oracleConfig) throws SQLException {
    Properties connectionProperties = new Properties();
    connectionProperties.setProperty(OracleConnection.CONNECTION_PROPERTY_INCLUDE_SYNONYMS, String.valueOf(oracleConfig.isSynonymsEnabled()));
    return new DriverConnectionFactory(new OracleDriver(), config.getConnectionUrl(), Optional.empty(), Optional.empty(), connectionProperties);
}
Also used : DriverConnectionFactory(com.facebook.presto.plugin.jdbc.DriverConnectionFactory) Properties(java.util.Properties) OracleDriver(oracle.jdbc.OracleDriver) Singleton(com.google.inject.Singleton) Provides(com.google.inject.Provides)

Aggregations

DriverConnectionFactory (com.facebook.presto.plugin.jdbc.DriverConnectionFactory)2 Properties (java.util.Properties)2 DriverConnectionFactory.basicConnectionProperties (com.facebook.presto.plugin.jdbc.DriverConnectionFactory.basicConnectionProperties)1 Provides (com.google.inject.Provides)1 Singleton (com.google.inject.Singleton)1 Driver (com.mysql.jdbc.Driver)1 OracleDriver (oracle.jdbc.OracleDriver)1