Thanks to visit codestin.com
Credit goes to github.com

Skip to content
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
Update HikariCP and move maxConnections parameter
  • Loading branch information
pesse committed Mar 19, 2019
commit aadebed24cf554af92bdb8556d17cf4e5ec8960b
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