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