1 package net.jaekl.squelch.db;
3 import java.sql.Connection;
4 import java.sql.DriverManager;
5 import java.sql.SQLException;
7 public abstract class DbDriver {
8 // Returns true iff. this DbDriver knows how to connect to the given JDBC URL
9 abstract public boolean handles(String jdbcUrl);
11 // Execute line as a statement of this type
12 abstract String getJdbcDriverClassName();
14 // Open a new Connection to the database. Note that the caller must close() this at some point.
15 public Connection connect(String jdbcUrl, String userName, String password) throws ClassNotFoundException, SQLException
17 Class.forName(getJdbcDriverClassName());
18 return DriverManager.getConnection(jdbcUrl, userName, password);