java/jdbc-loopback-driver/src/info/globalcode/jdbc/loopback/Driver.java
author František Kučera <franta-hg@frantovo.cz>
Sun, 06 Apr 2014 23:33:09 +0200
branchv_0
changeset 175 125d5805c5d8
parent 171 701ec4db43fb
child 177 5cc7fdad1452
permissions -rw-r--r--
Added tag v0.9 for changeset 3c6d560a1d14
     1 /**
     2  * SQL-DK
     3  * Copyright © 2014 František Kučera (frantovo.cz)
     4  *
     5  * This program is free software: you can redistribute it and/or modify
     6  * it under the terms of the GNU General Public License as published by
     7  * the Free Software Foundation, either version 3 of the License, or
     8  * (at your option) any later version.
     9  *
    10  * This program is distributed in the hope that it will be useful,
    11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    13  * GNU General Public License for more details.
    14  *
    15  * You should have received a copy of the GNU General Public License
    16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
    17  */
    18 package info.globalcode.jdbc.loopback;
    19 
    20 import java.sql.DriverManager;
    21 import java.sql.DriverPropertyInfo;
    22 import java.sql.SQLException;
    23 import java.sql.SQLFeatureNotSupportedException;
    24 import java.util.Properties;
    25 import java.util.logging.Level;
    26 import java.util.logging.Logger;
    27 
    28 /**
    29  *
    30  * @author Ing. František Kučera (frantovo.cz)
    31  */
    32 public class Driver implements java.sql.Driver {
    33 
    34 	private static final Logger log = Logger.getLogger(Driver.class.getName());
    35 
    36 	static {
    37 		try {
    38 			DriverManager.registerDriver(new Driver());
    39 		} catch (SQLException e) {
    40 			log.log(Level.SEVERE, "Unable to register JDBC driver", e);
    41 		}
    42 	}
    43 
    44 	@Override
    45 	public Connection connect(String url, Properties info) throws SQLException {
    46 		return new Connection(url, info);
    47 	}
    48 
    49 	@Override
    50 	public boolean acceptsURL(String url) throws SQLException {
    51 		return url != null && url.startsWith("jdbc:loopback://");
    52 	}
    53 
    54 	@Override
    55 	public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException {
    56 		return new DriverPropertyInfo[0];
    57 	}
    58 
    59 	@Override
    60 	public int getMajorVersion() {
    61 		return 0;
    62 	}
    63 
    64 	@Override
    65 	public int getMinorVersion() {
    66 		return 1;
    67 	}
    68 
    69 	@Override
    70 	public boolean jdbcCompliant() {
    71 		return false;
    72 	}
    73 
    74 	@Override
    75 	public Logger getParentLogger() throws SQLFeatureNotSupportedException {
    76 		throw new SQLFeatureNotSupportedException("Not supported yet.");
    77 	}
    78 
    79 }