/** * @return postgres connection */ private Connection getPostgresConnection() { Connection newConnection = null; try { LOG.finer("Creating a new database connection."); newConnection = DriverManager.getConnection( "jdbc:postgresql://" + loginCredentials.getHost() + "/" + loginCredentials.getDatabase(), // + "?logLevel=2" loginCredentials.getUser(), loginCredentials.getPassword() ); newConnection.setAutoCommit(autoCommit); } catch (SQLException e) { throw new OsmosisRuntimeException("Unable to establish a database connection.", e); } return newConnection; }
/** * @return postgres connection */ private Connection getPostgresConnection() { Connection newConnection = null; try { LOG.finer("Creating a new database connection."); newConnection = DriverManager.getConnection( "jdbc:postgresql://" + loginCredentials.getHost() + "/" + loginCredentials.getDatabase(), // + "?logLevel=2" loginCredentials.getUser(), loginCredentials.getPassword() ); newConnection.setAutoCommit(autoCommit); } catch (SQLException e) { throw new OsmosisRuntimeException("Unable to establish a database connection.", e); } return newConnection; }
private Connection getConnectionFromDriverManager() { try { return DriverManager.getConnection( "jdbc:postgresql://" + loginCredentials.getHost() + "/" + loginCredentials.getDatabase(), // + "?logLevel=2" loginCredentials.getUser(), loginCredentials.getPassword() ); } catch (SQLException e) { throw new OsmosisRuntimeException("Unable to establish a new database connection.", e); } }
private Connection createConnectionFromDriverManager() { try { // Register the database driver. try { Class.forName("org.postgresql.Driver"); } catch (ClassNotFoundException e) { throw new OsmosisRuntimeException("Unable to find database driver.", e); } return DriverManager.getConnection( "jdbc:postgresql://" + credentials.getHost() + "/" + credentials.getDatabase(), // + "?logLevel=2" credentials.getUser(), credentials.getPassword() ); } catch (SQLException e) { throw new OsmosisRuntimeException("Unable to establish a new database connection.", e); } }
/** * @return The mysql database connection. */ private Connection getMysqlConnection() { Connection newConnection = null; try { String url; url = "jdbc:mysql://" + loginCredentials.getHost() + "/" + loginCredentials.getDatabase() + "?user=" + loginCredentials.getUser() + "&password=" + loginCredentials.getPassword(); if (loginCredentials.getForceUtf8()) { url += "&useUnicode=true&characterEncoding=UTF-8"; } if (loginCredentials.getProfileSql()) { url += "&profileSql=true"; } newConnection = DriverManager.getConnection(url); newConnection.setAutoCommit(autoCommit); } catch (SQLException e) { throw new OsmosisRuntimeException("Unable to establish a database connection.", e); } return newConnection; }
/** * @return The mysql database connection. */ private Connection getMysqlConnection() { Connection newConnection = null; try { String url; url = "jdbc:mysql://" + loginCredentials.getHost() + "/" + loginCredentials.getDatabase() + "?user=" + loginCredentials.getUser() + "&password=" + loginCredentials.getPassword(); if (loginCredentials.getForceUtf8()) { url += "&useUnicode=true&characterEncoding=UTF-8"; } if (loginCredentials.getProfileSql()) { url += "&profileSql=true"; } newConnection = DriverManager.getConnection(url); newConnection.setAutoCommit(autoCommit); } catch (SQLException e) { throw new OsmosisRuntimeException("Unable to establish a database connection.", e); } return newConnection; }
private void createDataSource() { localDataSource = new BasicDataSource(); localDataSource.setDriverClassName("org.postgresql.Driver"); localDataSource.setUrl("jdbc:postgresql://" + credentials.getHost() + "/" + credentials.getDatabase() /*+ "?loglevel=2"*/); localDataSource.setUsername(credentials.getUser()); localDataSource.setPassword(credentials.getPassword()); dataSource = localDataSource; }
case POSTGRESQL: dataSource.setDriverClassName("org.postgresql.Driver"); dataSource.setUrl("jdbc:postgresql://" + credentials.getHost() + "/" + credentials.getDatabase() dataSource.setUrl("jdbc:mysql://" + credentials.getHost() + "/" + credentials.getDatabase()); break; default:
case POSTGRESQL: dataSource.setDriverClassName("org.postgresql.Driver"); dataSource.setUrl("jdbc:postgresql://" + credentials.getHost() + "/" + credentials.getDatabase() dataSource.setUrl("jdbc:mysql://" + credentials.getHost() + "/" + credentials.getDatabase()); break; default:
.getHost())); loginCredentials.setDatabase(getStringArgument(taskConfig, DatabaseConstants.TASK_ARG_DATABASE, loginCredentials.getDatabase())); loginCredentials.setUser(getStringArgument(taskConfig, DatabaseConstants.TASK_ARG_USER, loginCredentials .getUser()));
.getHost())); loginCredentials.setDatabase(getStringArgument(taskConfig, DatabaseConstants.TASK_ARG_DATABASE, loginCredentials.getDatabase())); loginCredentials.setUser(getStringArgument(taskConfig, DatabaseConstants.TASK_ARG_USER, loginCredentials .getUser()));