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());
37 private String userName;
38 private String password;
39 private Properties properties = new Properties();
41 @XmlElement(name = "name", namespace = CONFIGURATION)
43 public String getName() {
47 public void setName(String name) {
51 @XmlElement(name = "url", namespace = CONFIGURATION)
52 public String getUrl() {
56 public void setUrl(String url) {
60 @XmlElement(name = "userName", namespace = CONFIGURATION)
61 public String getUserName() {
65 public void setUserName(String userName) {
66 this.userName = userName;
69 @XmlElement(name = "password", namespace = CONFIGURATION)
70 public String getPassword() {
74 public void setPassword(String password) {
75 this.password = password;
78 @XmlElement(name = "property", namespace = CONFIGURATION)
79 public Properties getProperties() {
83 public void setProperties(Properties properties) {
84 this.properties = properties;
88 * @param properties ad-hoc properties from CLI options (for the JDBC driver)
89 * @param jmxBean JMX management bean for progress reporting | null = disable JMX
91 public DatabaseConnection connect(Properties properties, ConnectionManagement jmxBean) throws SQLException {
92 return new DatabaseConnection(this, properties, jmxBean);
96 * @see #connect(info.globalcode.sql.dk.configuration.Properties, java.lang.String)
97 * With disabled JMX reporting.
99 public DatabaseConnection connect(Properties properties) throws SQLException {
100 return new DatabaseConnection(this, properties, null);