Skip to content

Commit

Permalink
Produce a more actionable error on wrong JDBC URL
Browse files Browse the repository at this point in the history
  • Loading branch information
nineinchnick authored and wendigo committed Dec 7, 2023
1 parent a0f8178 commit dc880e9
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.Properties;
import java.util.logging.Logger;

import static com.google.common.base.Preconditions.checkState;
import static java.util.Objects.requireNonNull;

public class TracingDataSource
Expand Down Expand Up @@ -70,7 +71,9 @@ public JdbcDataSource(Driver driver, String connectionUrl, Properties properties
public Connection getConnection()
throws SQLException
{
return driver.connect(connectionUrl, properties);
Connection connection = driver.connect(connectionUrl, properties);
checkState(connection != null, "Driver returned null connection, make sure the connection URL '%s' is valid for the driver %s", connectionUrl, driver);
return connection;
}

@Override
Expand Down

0 comments on commit dc880e9

Please sign in to comment.