I am writing my own custom JDBC driver. I am wondering how I can configure the URL prefix to be passed to DriverManager.getConnection
in client code (i.e., the equivalent of jdbc:mysql when using mysql connector)? I seem to keep getting java.sql.SQLException: No suitable driver found
. My code currently looks like the following:
static
{
try
{
CustomDriver driverInst = new CustomDriver();
DriverManager.registerDriver(driverInst);
}
catch (Exception e) { e.printStackTrace(); }
}
public CustomDriver () throws SQLException
{
super();
}
@Override
public Connection connect (String url, Properties info) throws SQLException
{
// this is never called
return null;
}
test code:
Class.forName("CustomDriver");
System.out.println("Connecting to database...");
conn = DriverManager.getConnection("customDriver://localhost/testdb");
// throws SQLException