Skip to content

Update HikariCP and move maxConnections parameter #134

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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