java/sql-dk/src/main/java/info/globalcode/sql/dk/configuration/DatabaseDefinition.java
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, version 3 of the License.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 package info.globalcode.sql.dk.configuration;
19 import static info.globalcode.sql.dk.Xmlns.CONFIGURATION;
20 import info.globalcode.sql.dk.DatabaseConnection;
21 import info.globalcode.sql.dk.jmx.ConnectionManagement;
22 import java.sql.SQLException;
23 import java.util.logging.Logger;
24 import javax.xml.bind.annotation.XmlElement;
27 * Configured (but not yet connected) database connection.
29 * @author Ing. František Kučera (frantovo.cz)
31 public class DatabaseDefinition implements NameIdentified {
33 private static final Logger log = Logger.getLogger(DatabaseDefinition.class.getName());
35 * database name in SQL-DK configuration
45 private String userName;
49 private String password;
51 * optional JDBC driver – if empty, the DriverManager is used to lookup specific Driver for
54 private String driver;
58 private Properties properties = new Properties();
60 * optional definition of tunnel to the remote database
62 private TunnelDefinition tunnel;
64 @XmlElement(name = "name", namespace = CONFIGURATION)
66 public String getName() {
70 public void setName(String name) {
74 @XmlElement(name = "url", namespace = CONFIGURATION)
75 public String getUrl() {
79 public void setUrl(String url) {
83 @XmlElement(name = "userName", namespace = CONFIGURATION)
84 public String getUserName() {
88 public void setUserName(String userName) {
89 this.userName = userName;
92 @XmlElement(name = "password", namespace = CONFIGURATION)
93 public String getPassword() {
97 public void setPassword(String password) {
98 this.password = password;
101 public String getDriver() {
105 public void setDriver(String driver) {
106 this.driver = driver;
109 @XmlElement(name = "property", namespace = CONFIGURATION)
110 public Properties getProperties() {
114 public void setProperties(Properties properties) {
115 this.properties = properties;
118 public TunnelDefinition getTunnel() {
122 public void setTunnel(TunnelDefinition tunnel) {
123 this.tunnel = tunnel;
127 * @param properties ad-hoc properties from CLI options (for the JDBC driver)
128 * @param jmxBean JMX management bean for progress reporting | null = disable JMX
130 * @throws java.sql.SQLException
132 public DatabaseConnection connect(Properties properties, ConnectionManagement jmxBean) throws SQLException {
133 return new DatabaseConnection(this, properties, jmxBean);
139 * @throws java.sql.SQLException
140 * @see #connect(info.globalcode.sql.dk.configuration.Properties, java.lang.String)
141 * With disabled JMX reporting.
143 public DatabaseConnection connect(Properties properties) throws SQLException {
144 return new DatabaseConnection(this, properties, null);