-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
9 changed files
with
140 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
...source-creator/src/main/java/com/baomidou/dynamic/datasource/creator/c3p0/C3p0Config.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package com.baomidou.dynamic.datasource.creator.c3p0; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
|
||
/** | ||
* @author Joy | ||
*/ | ||
@Getter | ||
@Setter | ||
public class C3p0Config { | ||
private Integer acquireIncrement; | ||
private Integer acquireRetryAttempts; | ||
private Integer acquireRetryDelay; | ||
private Boolean attemptResurrectOnCheckin; | ||
private Boolean autoCommitOnClose; | ||
private String automaticTestTable; | ||
private Boolean breakAfterAcquireFailure; | ||
private Integer checkoutTimeout; | ||
private String connectionCustomizerClassName; | ||
private Integer connectionIsValidTimeout; | ||
private String connectionTesterClassName; | ||
private String contextClassLoaderSource; | ||
private Boolean debugUnreturnedConnectionStackTraces; | ||
private String factoryClassLocation; | ||
private Boolean forceIgnoreUnresolvedTransactions; | ||
private Boolean forceSynchronousCheckins; | ||
private Integer idleConnectionTestPeriod; | ||
private Integer initialPoolSize; | ||
private String markSessionBoundaries; | ||
private Integer maxAdministrativeTaskTime; | ||
private Integer maxConnectionAge; | ||
private Integer maxIdleTime; | ||
private Integer maxIdleTimeExcessConnections; | ||
private Integer maxPoolSize; | ||
private Integer maxStatements; | ||
private Integer maxStatementsPerConnection; | ||
private Integer minPoolSize; | ||
private String overrideDefaultPassword; | ||
private String overrideDefaultUser; | ||
private String preferredTestQuery; | ||
private Boolean privilegeSpawnedThreads; | ||
private Integer propertyCycle; | ||
private Integer statementCacheNumDeferredCloseThreads; | ||
private String taskRunnerFactoryClassName; | ||
private Boolean testConnectionOnCheckin; | ||
private Boolean testConnectionOnCheckout; | ||
private Integer unreturnedConnectionTimeout; | ||
} |
45 changes: 45 additions & 0 deletions
45
...tor/src/main/java/com/baomidou/dynamic/datasource/creator/c3p0/C3p0DataSourceCreator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.baomidou.dynamic.datasource.creator.c3p0; | ||
|
||
import com.baomidou.dynamic.datasource.creator.DataSourceCreator; | ||
import com.baomidou.dynamic.datasource.creator.DataSourceProperty; | ||
import com.baomidou.dynamic.datasource.enums.DdConstants; | ||
import com.baomidou.dynamic.datasource.toolkit.ConfigMergeCreator; | ||
import com.baomidou.dynamic.datasource.toolkit.DsStrUtils; | ||
import com.mchange.v2.c3p0.ComboPooledDataSource; | ||
import lombok.AllArgsConstructor; | ||
import lombok.NoArgsConstructor; | ||
import lombok.SneakyThrows; | ||
|
||
import javax.sql.DataSource; | ||
|
||
/** | ||
* @author Joy | ||
*/ | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class C3p0DataSourceCreator implements DataSourceCreator { | ||
|
||
private static final ConfigMergeCreator<C3p0Config, ComboPooledDataSource> MERGE_CREATOR = new ConfigMergeCreator<>("C3p0", C3p0Config.class, ComboPooledDataSource.class); | ||
|
||
private C3p0Config c3p0Config; | ||
|
||
@SneakyThrows | ||
@Override | ||
public DataSource createDataSource(DataSourceProperty dataSourceProperty) { | ||
ComboPooledDataSource dataSource = MERGE_CREATOR.create(c3p0Config, dataSourceProperty.getC3p0()); | ||
dataSource.setUser(dataSourceProperty.getUsername()); | ||
dataSource.setJdbcUrl(dataSourceProperty.getUrl()); | ||
dataSource.setPassword(dataSourceProperty.getPassword()); | ||
String driverClassName = dataSourceProperty.getDriverClassName(); | ||
if (DsStrUtils.hasText(driverClassName)) { | ||
dataSource.setDriverClass(driverClassName); | ||
} | ||
return dataSource; | ||
} | ||
|
||
@Override | ||
public boolean support(DataSourceProperty dataSourceProperty) { | ||
Class<? extends DataSource> type = dataSourceProperty.getType(); | ||
return type == null || DdConstants.C3P0_DATASOURCE.equals(type.getName()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters