1.1 --- a/java/sql-dk/src/info/globalcode/sql/dk/configuration/DatabaseDefinition.java Mon Mar 04 17:06:42 2019 +0100
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,147 +0,0 @@
1.4 -/**
1.5 - * SQL-DK
1.6 - * Copyright © 2013 František Kučera (frantovo.cz)
1.7 - *
1.8 - * This program is free software: you can redistribute it and/or modify
1.9 - * it under the terms of the GNU General Public License as published by
1.10 - * the Free Software Foundation, either version 3 of the License, or
1.11 - * (at your option) any later version.
1.12 - *
1.13 - * This program is distributed in the hope that it will be useful,
1.14 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.15 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.16 - * GNU General Public License for more details.
1.17 - *
1.18 - * You should have received a copy of the GNU General Public License
1.19 - * along with this program. If not, see <http://www.gnu.org/licenses/>.
1.20 - */
1.21 -package info.globalcode.sql.dk.configuration;
1.22 -
1.23 -import static info.globalcode.sql.dk.Xmlns.CONFIGURATION;
1.24 -import info.globalcode.sql.dk.DatabaseConnection;
1.25 -import info.globalcode.sql.dk.jmx.ConnectionManagement;
1.26 -import java.sql.SQLException;
1.27 -import java.util.logging.Logger;
1.28 -import javax.xml.bind.annotation.XmlElement;
1.29 -
1.30 -/**
1.31 - * Configured (but not yet connected) database connection.
1.32 - *
1.33 - * @author Ing. František Kučera (frantovo.cz)
1.34 - */
1.35 -public class DatabaseDefinition implements NameIdentified {
1.36 -
1.37 - private static final Logger log = Logger.getLogger(DatabaseDefinition.class.getName());
1.38 - /**
1.39 - * database name in SQL-DK configuration
1.40 - */
1.41 - private String name;
1.42 - /**
1.43 - * JDBC URL
1.44 - */
1.45 - private String url;
1.46 - /**
1.47 - * JDBC user name
1.48 - */
1.49 - private String userName;
1.50 - /**
1.51 - * JDBC password
1.52 - */
1.53 - private String password;
1.54 - /**
1.55 - * optional JDBC driver – if empty, the DriverManager is used to lookup specific Driver for
1.56 - * given URL
1.57 - */
1.58 - private String driver;
1.59 - /**
1.60 - * JDBC properties
1.61 - */
1.62 - private Properties properties = new Properties();
1.63 - /**
1.64 - * optional definition of tunnel to the remote database
1.65 - */
1.66 - private TunnelDefinition tunnel;
1.67 -
1.68 - @XmlElement(name = "name", namespace = CONFIGURATION)
1.69 - @Override
1.70 - public String getName() {
1.71 - return name;
1.72 - }
1.73 -
1.74 - public void setName(String name) {
1.75 - this.name = name;
1.76 - }
1.77 -
1.78 - @XmlElement(name = "url", namespace = CONFIGURATION)
1.79 - public String getUrl() {
1.80 - return url;
1.81 - }
1.82 -
1.83 - public void setUrl(String url) {
1.84 - this.url = url;
1.85 - }
1.86 -
1.87 - @XmlElement(name = "userName", namespace = CONFIGURATION)
1.88 - public String getUserName() {
1.89 - return userName;
1.90 - }
1.91 -
1.92 - public void setUserName(String userName) {
1.93 - this.userName = userName;
1.94 - }
1.95 -
1.96 - @XmlElement(name = "password", namespace = CONFIGURATION)
1.97 - public String getPassword() {
1.98 - return password;
1.99 - }
1.100 -
1.101 - public void setPassword(String password) {
1.102 - this.password = password;
1.103 - }
1.104 -
1.105 - public String getDriver() {
1.106 - return driver;
1.107 - }
1.108 -
1.109 - public void setDriver(String driver) {
1.110 - this.driver = driver;
1.111 - }
1.112 -
1.113 - @XmlElement(name = "property", namespace = CONFIGURATION)
1.114 - public Properties getProperties() {
1.115 - return properties;
1.116 - }
1.117 -
1.118 - public void setProperties(Properties properties) {
1.119 - this.properties = properties;
1.120 - }
1.121 -
1.122 - public TunnelDefinition getTunnel() {
1.123 - return tunnel;
1.124 - }
1.125 -
1.126 - public void setTunnel(TunnelDefinition tunnel) {
1.127 - this.tunnel = tunnel;
1.128 - }
1.129 -
1.130 - /**
1.131 - * @param properties ad-hoc properties from CLI options (for the JDBC driver)
1.132 - * @param jmxBean JMX management bean for progress reporting | null = disable JMX
1.133 - * @return
1.134 - * @throws java.sql.SQLException
1.135 - */
1.136 - public DatabaseConnection connect(Properties properties, ConnectionManagement jmxBean) throws SQLException {
1.137 - return new DatabaseConnection(this, properties, jmxBean);
1.138 - }
1.139 -
1.140 - /**
1.141 - * @param properties
1.142 - * @return
1.143 - * @throws java.sql.SQLException
1.144 - * @see #connect(info.globalcode.sql.dk.configuration.Properties, java.lang.String)
1.145 - * With disabled JMX reporting.
1.146 - */
1.147 - public DatabaseConnection connect(Properties properties) throws SQLException {
1.148 - return new DatabaseConnection(this, properties, null);
1.149 - }
1.150 -}