Skip to content

Commit

Permalink
Merge pull request #201 from hazendaz/master
Browse files Browse the repository at this point in the history
Migrate from dbcp to dbcp2 fixes #196
  • Loading branch information
hazendaz authored Nov 4, 2023
2 parents ae056c4 + 5a0f562 commit 988093e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
12 changes: 9 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,16 @@
<optional>true</optional>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.4</version>
<groupId>org.apache.commons</groupId>
<artifactId>commons-dbcp2</artifactId>
<version>2.11.0</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>jakarta.transaction</groupId>
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/com/ibatis/common/jdbc/DbcpConfiguration.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2004-2022 the original author or authors.
* Copyright 2004-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -18,12 +18,13 @@
import com.ibatis.common.beans.Probe;
import com.ibatis.common.beans.ProbeFactory;

import java.time.Duration;
import java.util.Iterator;
import java.util.Map;

import javax.sql.DataSource;

import org.apache.commons.dbcp.BasicDataSource;
import org.apache.commons.dbcp2.BasicDataSource;

/**
* Wrapper class to simplify use of DBCP.
Expand Down Expand Up @@ -151,15 +152,15 @@ private BasicDataSource legacyDbcpConfiguration(Map map) {
}

if (notEmpty(maxActive)) {
basicDataSource.setMaxActive(Integer.parseInt(maxActive));
basicDataSource.setMaxTotal(Integer.parseInt(maxActive));
}

if (notEmpty(maxIdle)) {
basicDataSource.setMaxIdle(Integer.parseInt(maxIdle));
}

if (notEmpty(maxWait)) {
basicDataSource.setMaxWait(Integer.parseInt(maxWait));
basicDataSource.setMaxWait(Duration.ofMillis(Integer.parseInt(maxWait)));
}

Iterator props = map.keySet().iterator();
Expand Down

0 comments on commit 988093e

Please sign in to comment.