use of io.prestosql.plugin.jdbc.DriverConnectionFactory in project hetu-core by openlookeng.
the class MySqlClientModule method createConnectionFactory.
@Provides
@Singleton
public static ConnectionFactory createConnectionFactory(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);
}
use of io.prestosql.plugin.jdbc.DriverConnectionFactory in project hetu-core by openlookeng.
the class TestDataSourceTableSplitManager method initSplitDatabase.
private void initSplitDatabase() throws SQLException {
String connectionUrl;
connectionUrl = "jdbc:h2:mem:test" + System.nanoTime() + ThreadLocalRandom.current().nextLong();
jdbcClient = new BaseJdbcClient(new BaseJdbcConfig(), "\"", new DriverConnectionFactory(new Driver(), connectionUrl, Optional.empty(), Optional.empty(), new Properties()));
connection = DriverManager.getConnection(connectionUrl);
}
use of io.prestosql.plugin.jdbc.DriverConnectionFactory in project hetu-core by openlookeng.
the class ClickHouseClientModule method createConnectionFactory.
@Provides
@Singleton
public static ConnectionFactory createConnectionFactory(BaseJdbcConfig config, ClickHouseConfig clickHouseConfig) {
Properties connectionProperties = basicConnectionProperties(config);
connectionProperties.setProperty(ClickHouseConnectionSettings.SOCKET_TIMEOUT.getKey(), String.valueOf(clickHouseConfig.getSocketTimeout()));
return new DriverConnectionFactory(new ClickHouseDriver(), config.getConnectionUrl(), Optional.ofNullable(config.getUserCredentialName()), Optional.ofNullable(config.getPasswordCredentialName()), connectionProperties);
}
use of io.prestosql.plugin.jdbc.DriverConnectionFactory in project hetu-core by openlookeng.
the class OracleClientModule method getConnectionFactory.
/**
* getConnectionFactory
*
* @param config config
* @return ConnectionFactory
*/
@Provides
@Singleton
public static ConnectionFactory getConnectionFactory(BaseJdbcConfig config, OracleConfig oracleConfig) {
Properties connectionProperties = basicConnectionProperties(config);
connectionProperties.setProperty(Constants.ORACLE_PROPERTY_INCLUDE_SYNONYMS, String.valueOf(oracleConfig.isSynonymsEnabled()));
Driver driver;
try {
driver = (Driver) Class.forName(Constants.ORACLE_JDBC_DRIVER_CLASS_NAME).getConstructor(((Class<?>[]) null)).newInstance();
} catch (InstantiationException | ClassNotFoundException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
throw new PrestoException(JDBC_ERROR, e);
}
return new DriverConnectionFactory(driver, config.getConnectionUrl(), Optional.ofNullable(config.getUserCredentialName()), Optional.ofNullable(config.getPasswordCredentialName()), connectionProperties);
}
use of io.prestosql.plugin.jdbc.DriverConnectionFactory in project hetu-core by openlookeng.
the class HanaClientModule method getConnectionFactory.
/**
* createConnectionFactory
*
* @param config BaseJdbcConfig
* @param hanaConfig HanaConfig
* @return ConnectionFactory
*/
@Provides
@Singleton
public static ConnectionFactory getConnectionFactory(BaseJdbcConfig config, HanaConfig hanaConfig) {
Properties connectionProperties = basicConnectionProperties(config);
connectionProperties.setProperty("autocommit", String.valueOf(hanaConfig.isAutoCommit()));
connectionProperties.setProperty("communicationTimeout", String.valueOf(hanaConfig.getCommunicationTimeout()));
connectionProperties.setProperty("encrypt", String.valueOf(hanaConfig.isEncrypt()));
connectionProperties.setProperty("packetsize", String.valueOf(hanaConfig.getPacketSize()));
connectionProperties.setProperty("readOnly", String.valueOf(hanaConfig.isReadOnly()));
connectionProperties.setProperty("reconnect", String.valueOf(hanaConfig.isReconnect()));
log.info("Hana connection properties: %s", connectionProperties);
Driver driver = null;
try {
driver = (Driver) Class.forName(HanaConstants.SAP_HANA_JDBC_DRIVER_CLASS_NAME).getConstructor(((Class<?>[]) null)).newInstance();
} catch (InstantiationException e) {
throw new PrestoException(JDBC_ERROR, e);
} catch (IllegalAccessException e) {
throw new PrestoException(JDBC_ERROR, e);
} catch (ClassNotFoundException e) {
throw new PrestoException(JDBC_ERROR, e);
} catch (InvocationTargetException e) {
throw new PrestoException(JDBC_ERROR, e);
} catch (NoSuchMethodException e) {
throw new PrestoException(JDBC_ERROR, e);
}
return new DriverConnectionFactory(driver, config.getConnectionUrl(), Optional.ofNullable(config.getUserCredentialName()), Optional.ofNullable(config.getPasswordCredentialName()), connectionProperties);
}
Aggregations