Avoid reusing/rewriting the DB connection properties.
There was weird random errors while testing connection to multiple DB in parallel when one of them was meta connection to same DB connection.
Two kinds of exception: 1) missing password 2) „Passing DB password as CLI parameter is insecure!“
3 * Copyright © 2014 František Kučera (frantovo.cz)
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.
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.
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/>.
18 package info.globalcode.jdbc.loopback;
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;
30 * @author Ing. František Kučera (frantovo.cz)
32 public class Driver implements java.sql.Driver {
34 private static final Logger log = Logger.getLogger(Driver.class.getName());
38 DriverManager.registerDriver(new Driver());
39 } catch (SQLException e) {
40 log.log(Level.SEVERE, "Unable to register JDBC driver", e);
45 public Connection connect(String url, Properties info) throws SQLException {
46 if (acceptsURL(url)) {
47 return new Connection(url, info);
49 // The driver should return "null" if it realizes it is the wrong kind of driver to connect to the given URL.
55 public boolean acceptsURL(String url) throws SQLException {
56 return url != null && url.startsWith("jdbc:loopback://");
60 public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException {
61 return new DriverPropertyInfo[0];
65 public int getMajorVersion() {
70 public int getMinorVersion() {
75 public boolean jdbcCompliant() {
80 public Logger getParentLogger() throws SQLFeatureNotSupportedException {
81 throw new SQLFeatureNotSupportedException("Not supported yet.");