slight improvements to error messages when driver class missing

This commit is contained in:
Gavin King 2024-10-18 13:06:36 +02:00
parent a9fb252e1d
commit 044d91411f
4 changed files with 9 additions and 4 deletions

View File

@ -34,7 +34,7 @@ public class DriverManagerConnectionCreator extends BasicConnectionCreator {
return DriverManager.getConnection( url, connectionProps ); return DriverManager.getConnection( url, connectionProps );
} }
catch (SQLException e) { catch (SQLException e) {
throw convertSqlException( "Error calling DriverManager.getConnection()", e ); throw convertSqlException( "Error calling JDBC 'DriverManager.getConnection()'", e );
} }
} }
} }

View File

@ -517,7 +517,7 @@ public interface CoreMessageLogger extends BasicLogger {
void unableToObtainConnectionMetadata(SQLException error); void unableToObtainConnectionMetadata(SQLException error);
@LogMessage(level = WARN) @LogMessage(level = WARN)
@Message(value = "Could not obtain connection to query metadata", id = 342) @Message(value = "Could not obtain connection to query JDBC database metadata", id = 342)
void unableToObtainConnectionToQueryMetadata(@Cause Exception e); void unableToObtainConnectionToQueryMetadata(@Cause Exception e);
@LogMessage(level = ERROR) @LogMessage(level = ERROR)

View File

@ -7,6 +7,7 @@ package org.hibernate.internal.log;
import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodHandles;
import java.sql.SQLException; import java.sql.SQLException;
import org.hibernate.cfg.JdbcSettings;
import org.jboss.logging.BasicLogger; import org.jboss.logging.BasicLogger;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
import org.jboss.logging.annotations.Cause; import org.jboss.logging.annotations.Cause;
@ -45,7 +46,11 @@ public interface ConnectionInfoLogger extends BasicLogger {
void logConnectionInfoDetails(String databaseConnectionInfo); void logConnectionInfoDetails(String databaseConnectionInfo);
@LogMessage(level = WARN) @LogMessage(level = WARN)
@Message(id = 10001006, value = "No JDBC Driver class was specified by property `jakarta.persistence.jdbc.driver`, `hibernate.driver` or `javax.persistence.jdbc.driver`") @Message(id = 10001006,
value = "No JDBC Driver class was specified by property '"
+ JdbcSettings.JAKARTA_JDBC_DRIVER + "', '"
+ JdbcSettings.JPA_JDBC_DRIVER + "', or '"
+ JdbcSettings.DRIVER + "'")
void jdbcDriverNotSpecified(); void jdbcDriverNotSpecified();
@LogMessage(level = DEBUG) @LogMessage(level = DEBUG)

View File

@ -13,12 +13,12 @@ import org.hibernate.resource.beans.spi.BeanInstanceProducer;
/** /**
* @author Yanming Zhou * @author Yanming Zhou
*/ */
@SuppressWarnings("unchecked")
public class SimpleBeanContainer implements BeanContainer { public class SimpleBeanContainer implements BeanContainer {
public static final long INITIAL_VALUE = 23L; public static final long INITIAL_VALUE = 23L;
@Override @Override
@SuppressWarnings("unchecked")
public <B> ContainedBean<B> getBean( public <B> ContainedBean<B> getBean(
Class<B> beanType, Class<B> beanType,
LifecycleOptions lifecycleOptions, LifecycleOptions lifecycleOptions,