parallel connection testing: avoid deadlocks – preload drivers + better exception handling and logging
3 * Copyright © 2013 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.sql.dk.configuration;
20 import static info.globalcode.sql.dk.Xmlns.CONFIGURATION;
21 import info.globalcode.sql.dk.DatabaseConnection;
22 import info.globalcode.sql.dk.jmx.ConnectionManagement;
23 import java.sql.SQLException;
24 import java.util.logging.Logger;
25 import javax.xml.bind.annotation.XmlElement;
28 * Configured (but not yet connected) database connection.
30 * @author Ing. František Kučera (frantovo.cz)
32 public class DatabaseDefinition implements NameIdentified {
34 private static final Logger log = Logger.getLogger(DatabaseDefinition.class.getName());
36 * database name in SQL-DK configuration
46 private String userName;
50 private String password;
52 * optional JDBC driver – if empty, the DriverManager is used to lookup specific Driver for
55 private String driver;
59 private Properties properties = new Properties();
61 @XmlElement(name = "name", namespace = CONFIGURATION)
63 public String getName() {
67 public void setName(String name) {
71 @XmlElement(name = "url", namespace = CONFIGURATION)
72 public String getUrl() {
76 public void setUrl(String url) {
80 @XmlElement(name = "userName", namespace = CONFIGURATION)
81 public String getUserName() {
85 public void setUserName(String userName) {
86 this.userName = userName;
89 @XmlElement(name = "password", namespace = CONFIGURATION)
90 public String getPassword() {
94 public void setPassword(String password) {
95 this.password = password;
98 public String getDriver() {
102 public void setDriver(String driver) {
103 this.driver = driver;
106 @XmlElement(name = "property", namespace = CONFIGURATION)
107 public Properties getProperties() {
111 public void setProperties(Properties properties) {
112 this.properties = properties;
116 * @param properties ad-hoc properties from CLI options (for the JDBC driver)
117 * @param jmxBean JMX management bean for progress reporting | null = disable JMX
119 * @throws java.sql.SQLException
121 public DatabaseConnection connect(Properties properties, ConnectionManagement jmxBean) throws SQLException {
122 return new DatabaseConnection(this, properties, jmxBean);
128 * @throws java.sql.SQLException
129 * @see #connect(info.globalcode.sql.dk.configuration.Properties, java.lang.String)
130 * With disabled JMX reporting.
132 public DatabaseConnection connect(Properties properties) throws SQLException {
133 return new DatabaseConnection(this, properties, null);