Skip to content

Commit

Permalink
Merge pull request #134 from utPLSQL/feature/update_hikaricp
Browse files Browse the repository at this point in the history
Update HikariCP and move maxConnections parameter
Fixes #123
  • Loading branch information
pesse authored Mar 19, 2019
2 parents bbc2ebc + aadebed commit 4ece1d4
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>2.7.2</version>
<version>3.3.1</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand Down
5 changes: 1 addition & 4 deletions src/main/java/org/utplsql/cli/DataSourceProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ public static DataSource getDataSource(ConnectionInfo info, int maxConnections )
ConnectionConfig config = new ConnectionConfig(info.getConnectionString());
warnIfSysDba(config);

HikariDataSource pds = new TestedDataSourceProvider(config).getDataSource();
pds.setAutoCommit(false);
pds.setMaximumPoolSize(maxConnections);
return pds;
return new TestedDataSourceProvider(config, maxConnections).getDataSource();
}

private static void requireOjdbc() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ interface ConnectStringPossibility {
private static final Logger logger = LoggerFactory.getLogger(TestedDataSourceProvider.class);
private final ConnectionConfig config;
private final List<ConnectStringPossibility> possibilities = new ArrayList<>();
private final int maxConnections;

public TestedDataSourceProvider(ConnectionConfig config) {
public TestedDataSourceProvider(ConnectionConfig config, int maxConnections) {
this.config = config;
this.maxConnections = maxConnections;

possibilities.add(new ThickConnectStringPossibility());
possibilities.add(new ThinConnectStringPossibility());
Expand All @@ -35,6 +37,8 @@ public TestedDataSourceProvider(ConnectionConfig config) {
public HikariDataSource getDataSource() throws SQLException {

HikariDataSource ds = new HikariDataSource();
ds.setAutoCommit(false);
ds.setMaximumPoolSize(maxConnections);

setInitSqlFrom_NLS_LANG(ds);
setThickOrThinJdbcUrl(ds);
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/org/utplsql/cli/DataSourceProviderIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void connectToDatabase() throws SQLException {
//@Test
void connectAsSysdba() throws SQLException {
ConnectionConfig config = new ConnectionConfig("sys as sysdba/oracle@localhost:1522/ORCLPDB1");
DataSource dataSource = new TestedDataSourceProvider(config).getDataSource();
DataSource dataSource = new TestedDataSourceProvider(config, 2).getDataSource();

assertNotNull(dataSource);
}
Expand Down Expand Up @@ -66,7 +66,7 @@ void initNlsLangEmpty() throws SQLException {

private DataSource getDataSource() throws SQLException {
ConnectionConfig config = new ConnectionConfig(TestHelper.getConnectionString());
return new TestedDataSourceProvider(config).getDataSource();
return new TestedDataSourceProvider(config, 2).getDataSource();
}

private void checkNlsSessionParameter( DataSource dataSource, String parameterName, String expectedValue ) throws SQLException {
Expand Down

0 comments on commit 4ece1d4

Please sign in to comment.