-
Notifications
You must be signed in to change notification settings - Fork 41.6k
Add support for Oracle UCP #23403
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
Add support for Oracle UCP #23403
Changes from 2 commits
713eba3
aa6136a
6cb3a61
ec15fc8
ada64e0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,6 +21,7 @@ dependencies { | |
| optional("com.atomikos:transactions-jta") | ||
| optional("com.fasterxml.jackson.core:jackson-databind") | ||
| optional("com.google.code.gson:gson") | ||
| optional("com.oracle.ojdbc:ucp") | ||
|
||
| optional("com.samskivert:jmustache") | ||
| optional("com.zaxxer:HikariCP") | ||
| optional("io.netty:netty-tcnative-boringssl-static") | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| /* | ||
| * Copyright 2012-2019 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. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * https://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.springframework.boot.jdbc.metadata; | ||
|
|
||
| import java.sql.SQLException; | ||
|
|
||
| import javax.sql.DataSource; | ||
|
|
||
| import oracle.ucp.jdbc.PoolDataSource; | ||
|
|
||
| import org.springframework.dao.InvalidDataAccessApiUsageException; | ||
| import org.springframework.util.StringUtils; | ||
|
|
||
| /** | ||
| * {@link DataSourcePoolMetadata} for a Oracle UCP {@link DataSource}. | ||
| * | ||
| * @author Fabio Grassi | ||
| * @since 2.3.4 | ||
| */ | ||
| public class UcpDataSourcePoolMetadata extends AbstractDataSourcePoolMetadata<PoolDataSource> { | ||
|
|
||
| public UcpDataSourcePoolMetadata(PoolDataSource dataSource) { | ||
| super(dataSource); | ||
| } | ||
|
|
||
| @Override | ||
| public Integer getActive() { | ||
| try { | ||
| return getDataSource().getBorrowedConnectionsCount(); | ||
| } | ||
| catch (SQLException e) { | ||
| throw new InvalidDataAccessApiUsageException("Error while reading property borrowedConnectionsCount", e); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public Integer getIdle() { | ||
| try { | ||
| return getDataSource().getAvailableConnectionsCount(); | ||
| } | ||
| catch (SQLException e) { | ||
| throw new InvalidDataAccessApiUsageException("Error while reading property availableConnectionsCount", e); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public Integer getMax() { | ||
| return getDataSource().getMaxPoolSize(); | ||
| } | ||
|
|
||
| @Override | ||
| public Integer getMin() { | ||
| return getDataSource().getMinPoolSize(); | ||
| } | ||
|
|
||
| @Override | ||
| public String getValidationQuery() { | ||
| return getDataSource().getSQLForValidateConnection(); | ||
| } | ||
|
|
||
| @Override | ||
| public Boolean getDefaultAutoCommit() { | ||
| String ac = getDataSource().getConnectionProperties().getProperty("AutoCommit"); | ||
| return StringUtils.hasText(ac) ? Boolean.valueOf(ac) : null; | ||
| } | ||
|
|
||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just realized I used the old groupId for Oracle. It would be better replace "com.oracle.ojdbc" with "com.oracle.database.jdbc".