java/jdbc-loopback-driver/src/main/java/info/globalcode/jdbc/loopback/Driver.java
/**
* SQL-DK
* Copyright © 2014 František Kučera (frantovo.cz)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package info.globalcode.jdbc.loopback;
import java.sql.DriverManager;
import java.sql.DriverPropertyInfo;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
* @author Ing. František Kučera (frantovo.cz)
*/
public class Driver implements java.sql.Driver {
private static final Logger log = Logger.getLogger(Driver.class.getName());
static {
try {
DriverManager.registerDriver(new Driver());
} catch (SQLException e) {
log.log(Level.SEVERE, "Unable to register JDBC driver", e);
}
}
@Override
public Connection connect(String url, Properties info) throws SQLException {
if (acceptsURL(url)) {
return new Connection(url, info);
} else {
// The driver should return "null" if it realizes it is the wrong kind of driver to connect to the given URL.
return null;
}
}
@Override
public boolean acceptsURL(String url) throws SQLException {
return url != null && url.startsWith("jdbc:loopback://");
}
@Override
public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException {
return new DriverPropertyInfo[0];
}
@Override
public int getMajorVersion() {
return 0;
}
@Override
public int getMinorVersion() {
return 1;
}
@Override
public boolean jdbcCompliant() {
return false;
}
@Override
public Logger getParentLogger() throws SQLFeatureNotSupportedException {
throw new SQLFeatureNotSupportedException("Not supported yet.");
}
}