Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiyv-improving committed Nov 17, 2023
1 parent 81fc5b4 commit 1b89a9d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
* <p>THIS CLASS IS NOT MULTI-THREADING SAFE IT'S EXPECTED TO HAVE ONE INSTANCE OF THIS MANAGER PER
* JDBC CONNECTION
*/
@SuppressWarnings("deprecation")
public class ConnectionPluginManager implements CanReleaseResources, Wrapper {

protected static final Map<Class<? extends ConnectionPlugin>, String> pluginNameByClass =
Expand Down
18 changes: 11 additions & 7 deletions wrapper/src/main/java/software/amazon/jdbc/Driver.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,17 @@ public Connection connect(final String url, final Properties info) throws SQLExc

LOGGER.finest("Opening connection to " + url);

final String databaseName = ConnectionUrlParser.parseDatabaseFromUrl(url);
ConnectionUrlParser.parsePropertiesFromUrl(url, info);
final Properties props = PropertyUtils.copyProperties(info);

final String profileName = PropertyDefinition.PROFILE_NAME.getString(info);
final String databaseName = ConnectionUrlParser.parseDatabaseFromUrl(url);
if (!StringUtils.isNullOrEmpty(databaseName)) {
PropertyDefinition.DATABASE.set(props, databaseName);
}

LOGGER.finest(() -> PropertyUtils.logProperties(props, "DEBUG: Connecting with properties: \n"));

final String profileName = PropertyDefinition.PROFILE_NAME.getString(props);
ConfigurationProfile configurationProfile = null;
if (!StringUtils.isNullOrEmpty(profileName)) {
configurationProfile = DriverConfigurationProfiles.getProfileConfiguration(profileName);
Expand All @@ -120,11 +126,8 @@ public Connection connect(final String url, final Properties info) throws SQLExc
new Object[] {profileName}));
}
}
if (!StringUtils.isNullOrEmpty(databaseName)) {
PropertyDefinition.DATABASE.set(info, databaseName);
}

TelemetryFactory telemetryFactory = new DefaultTelemetryFactory(info);
TelemetryFactory telemetryFactory = new DefaultTelemetryFactory(props);
TelemetryContext context = telemetryFactory.openTelemetryContext(
"software.amazon.jdbc.Driver.connect", TelemetryTraceLevel.TOP_LEVEL);

Expand Down Expand Up @@ -152,7 +155,7 @@ public Connection connect(final String url, final Properties info) throws SQLExc
return null;
}

final String logLevelStr = PropertyDefinition.LOGGER_LEVEL.getString(info);
final String logLevelStr = PropertyDefinition.LOGGER_LEVEL.getString(props);
if (!StringUtils.isNullOrEmpty(logLevelStr)) {
final Level logLevel = Level.parse(logLevelStr.toUpperCase());
final Logger rootLogger = Logger.getLogger("");
Expand Down Expand Up @@ -191,6 +194,7 @@ public Connection connect(final String url, final Properties info) throws SQLExc
targetDriverDialect,
configurationProfile,
telemetryFactory);

} catch (Exception ex) {
context.setException(ex);
context.setSuccess(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ public Connection connect(
final @NonNull Properties props)
throws SQLException {

LOGGER.finest(() -> "DEBUG: Connecting with properties:\n"
+ PropertyUtils.logProperties(props, ""));

final Properties copy = PropertyUtils.copyProperties(props);
dialect.prepareConnectProperties(copy, protocol, hostSpec);
final ConnectInfo connectInfo = targetDriverDialect.prepareConnectInfo(protocol, hostSpec, copy);
Expand Down

0 comments on commit 1b89a9d

Please sign in to comment.