Skip to content

Commit 2487390

Browse files
committed
report the name of the ConnectionProvider along with the other info
1 parent 879dca2 commit 2487390

File tree

8 files changed

+29
-12
lines changed

8 files changed

+29
-12
lines changed

hibernate-agroal/src/main/java/org/hibernate/agroal/internal/AgroalConnectionProvider.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ public DatabaseConnectionInfo getDatabaseConnectionInfo(Dialect dialect) {
167167
agroalDataSource.getConfiguration().connectionPoolConfiguration();
168168
final AgroalConnectionFactoryConfiguration acfc = acpc.connectionFactoryConfiguration();
169169
return new DatabaseConnectionInfoImpl(
170+
AgroalConnectionProvider.class,
170171
acfc.jdbcUrl(),
171172
// Attempt to resolve the driver name from the dialect,
172173
// in case it wasn't explicitly set and access to the

hibernate-c3p0/src/main/java/org/hibernate/c3p0/internal/C3P0ConnectionProvider.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ public void configure(Map<String, Object> properties) {
152152
dataSource = createDataSource( jdbcUrl, connectionProps, poolSettings );
153153

154154
dbInfoProducer = dialect -> new DatabaseConnectionInfoImpl(
155+
C3P0ConnectionProvider.class,
155156
jdbcUrl,
156157
jdbcDriverClass,
157158
dialect.getVersion(),

hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/DatabaseConnectionInfoImpl.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import org.hibernate.cfg.JdbcSettings;
1010
import org.hibernate.dialect.DatabaseVersion;
1111
import org.hibernate.dialect.Dialect;
12+
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
1213
import org.hibernate.engine.jdbc.connections.spi.DatabaseConnectionInfo;
1314
import org.hibernate.internal.util.NullnessHelper;
1415
import org.hibernate.internal.util.StringHelper;
@@ -27,6 +28,7 @@
2728
public class DatabaseConnectionInfoImpl implements DatabaseConnectionInfo {
2829
public static final String DEFAULT = "undefined/unknown";
2930

31+
private final Class<?> connectionProviderClass;
3032
protected final String jdbcUrl;
3133
protected final String jdbcDriver;
3234
protected final DatabaseVersion dialectVersion;
@@ -36,13 +38,15 @@ public class DatabaseConnectionInfoImpl implements DatabaseConnectionInfo {
3638
protected final Integer poolMaxSize;
3739

3840
public DatabaseConnectionInfoImpl(
41+
Class<? extends ConnectionProvider> connectionProviderClass,
3942
String jdbcUrl,
4043
String jdbcDriver,
4144
DatabaseVersion dialectVersion,
4245
String autoCommitMode,
4346
String isolationLevel,
4447
Integer poolMinSize,
4548
Integer poolMaxSize) {
49+
this.connectionProviderClass = connectionProviderClass;
4650
this.jdbcUrl = nullIfEmpty( jdbcUrl );
4751
this.jdbcDriver = nullIfEmpty( jdbcDriver );
4852
this.dialectVersion = dialectVersion;
@@ -54,6 +58,7 @@ public DatabaseConnectionInfoImpl(
5458

5559
public DatabaseConnectionInfoImpl(Map<String, Object> settings, Dialect dialect) {
5660
this(
61+
null,
5762
determineUrl( settings ),
5863
determineDriver( settings ),
5964
dialect.getVersion(),
@@ -66,7 +71,7 @@ public DatabaseConnectionInfoImpl(Map<String, Object> settings, Dialect dialect)
6671
}
6772

6873
public DatabaseConnectionInfoImpl(Dialect dialect) {
69-
this( null, null, dialect.getVersion(), null, null, null, null );
74+
this( null, null, null, dialect.getVersion(), null, null, null, null );
7075
}
7176

7277
@Override
@@ -111,6 +116,7 @@ public String toInfoString() {
111116
"\n\tDatabase version: " + handleEmpty( dialectVersion ) +
112117
"\n\tAutocommit mode: " + handleEmpty( autoCommitMode ) +
113118
"\n\tIsolation level: " + handleEmpty( isolationLevel ) +
119+
"\n\tPool: " + handleEmpty( connectionProviderClass ) +
114120
"\n\tMinimum pool size: " + handleEmpty( poolMinSize ) +
115121
"\n\tMaximum pool size: " + handleEmpty( poolMaxSize );
116122
}
@@ -127,6 +133,10 @@ private static String handleEmpty(Integer value) {
127133
return value != null ? value.toString() : DEFAULT;
128134
}
129135

136+
private static String handleEmpty(Class<?> value) {
137+
return value != null ? value.getSimpleName() : DEFAULT;
138+
}
139+
130140

131141
@SuppressWarnings("deprecation")
132142
private static String determineUrl(Map<String, Object> settings) {

hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/DatasourceConnectionProviderImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ public boolean supportsAggressiveRelease() {
150150
@Override
151151
public DatabaseConnectionInfo getDatabaseConnectionInfo(Dialect dialect) {
152152
return new DatabaseConnectionInfoImpl(
153+
DatasourceConnectionProviderImpl.class,
153154
null,
154155
null,
155156
dialect.getVersion(),

hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/DriverManagerConnectionProviderImpl.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ private static ConnectionCreator buildCreator(
142142
final ConnectionCreatorFactory factory = getConnectionCreatorFactory( configurationValues, serviceRegistry );
143143

144144
dbInfo = new DatabaseConnectionInfoImpl(
145+
DriverManagerConnectionProviderImpl.class,
145146
url,
146147
driverList,
147148
SimpleDatabaseVersion.ZERO_VERSION,
@@ -283,6 +284,7 @@ public boolean supportsAggressiveRelease() {
283284
@Override
284285
public DatabaseConnectionInfo getDatabaseConnectionInfo(Dialect dialect) {
285286
return new DatabaseConnectionInfoImpl(
287+
DriverManagerConnectionProviderImpl.class,
286288
dbInfo.getJdbcUrl(),
287289
dbInfo.getJdbcDriver(),
288290
dialect.getVersion(),

hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/spi/DataSourceBasedMultiTenantConnectionProviderImpl.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,30 +72,29 @@ private Map<T, DataSource> dataSourceMap() {
7272
public void injectServices(ServiceRegistryImplementor serviceRegistry) {
7373
final ConfigurationService configurationService = serviceRegistry.requireService( ConfigurationService.class );
7474
final Object dataSourceConfigValue = configurationService.getSettings().get( DATASOURCE );
75-
if ( !(dataSourceConfigValue instanceof String) ) {
75+
if ( !(dataSourceConfigValue instanceof String configuredJndiName) ) {
7676
throw new HibernateException( "illegal value for configuration setting '" + DATASOURCE + "'" );
7777
}
78-
jndiName = (String) dataSourceConfigValue;
78+
jndiName = configuredJndiName;
7979

8080
jndiService = serviceRegistry.getService( JndiService.class );
8181
if ( jndiService == null ) {
8282
throw new HibernateException( "Could not locate JndiService from DataSourceBasedMultiTenantConnectionProviderImpl" );
8383
}
8484

85-
final Object namedObject = jndiService.locate( jndiName );
85+
final Object namedObject = jndiService.locate( this.jndiName );
8686
if ( namedObject == null ) {
87-
throw new HibernateException( "JNDI name [" + jndiName + "] could not be resolved" );
87+
throw new HibernateException( "JNDI name [" + this.jndiName + "] could not be resolved" );
8888
}
89-
90-
if ( namedObject instanceof DataSource datasource ) {
91-
final int loc = jndiName.lastIndexOf( '/' );
92-
baseJndiNamespace = jndiName.substring( 0, loc );
93-
final String prefix = jndiName.substring(loc + 1);
89+
else if ( namedObject instanceof DataSource datasource ) {
90+
final int loc = this.jndiName.lastIndexOf( '/' );
91+
baseJndiNamespace = this.jndiName.substring( 0, loc );
92+
final String prefix = this.jndiName.substring( loc + 1);
9493
tenantIdentifierForAny = (T) prefix;
9594
dataSourceMap().put( tenantIdentifierForAny, datasource );
9695
}
9796
else if ( namedObject instanceof Context ) {
98-
baseJndiNamespace = jndiName;
97+
baseJndiNamespace = this.jndiName;
9998
final Object configuredTenantId =
10099
configurationService.getSettings().get( TENANT_IDENTIFIER_TO_USE_FOR_ANY_KEY );
101100
tenantIdentifierForAny = (T) configuredTenantId;
@@ -106,7 +105,7 @@ else if ( namedObject instanceof Context ) {
106105
else {
107106
throw new HibernateException(
108107
"Unknown object type [" + namedObject.getClass().getName() +
109-
"] found in JNDI location [" + jndiName + "]"
108+
"] found in JNDI location [" + this.jndiName + "]"
110109
);
111110
}
112111
}
@@ -119,6 +118,7 @@ public void stop() {
119118
@Override
120119
public DatabaseConnectionInfo getDatabaseConnectionInfo(Dialect dialect) {
121120
return new DatabaseConnectionInfoImpl(
121+
null,
122122
null,
123123
null,
124124
dialect.getVersion(),

hibernate-hikaricp/src/main/java/org/hibernate/hikaricp/internal/HikariCPConnectionProvider.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ public boolean supportsAggressiveRelease() {
9595
@Override
9696
public DatabaseConnectionInfo getDatabaseConnectionInfo(Dialect dialect) {
9797
return new DatabaseConnectionInfoImpl(
98+
HikariCPConnectionProvider.class,
9899
hikariConfig.getJdbcUrl(),
99100
// Attempt to resolve the driver name from the dialect, in case it wasn't explicitly set and access to
100101
// the database metadata is allowed

hibernate-ucp/src/main/java/org/hibernate/oracleucp/internal/UCPConnectionProvider.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ public boolean supportsAggressiveRelease() {
182182
@Override
183183
public DatabaseConnectionInfo getDatabaseConnectionInfo(Dialect dialect) {
184184
return new DatabaseConnectionInfoImpl(
185+
UCPConnectionProvider.class,
185186
ucpDS.getURL(),
186187
ucpDS.getConnectionFactoryClassName(),
187188
dialect.getVersion(),

0 commit comments

Comments
 (0)