diff --git a/src/tap/config/ConfigurableTAPFactory.java b/src/tap/config/ConfigurableTAPFactory.java index 28b90f1f37b7285fbbcbc137d9993aab67013421..91932554d2a7c4c8a47dc6f20523c2af07fae2ce 100644 --- a/src/tap/config/ConfigurableTAPFactory.java +++ b/src/tap/config/ConfigurableTAPFactory.java @@ -139,10 +139,10 @@ public class ConfigurableTAPFactory extends AbstractTAPFactory { if (jdbcDriver == null){ if (dbUrl == null) throw new TAPException("The property \"" + KEY_JDBC_URL + "\" is missing! Since the choosen database access method is \"" + VALUE_JDBC + "\", this property is required."); - else if (!dbUrl.startsWith(JDBCConnection.JDBC_PREFIX + ":")) - throw new TAPException("JDBC URL format incorrect! It MUST begins with " + JDBCConnection.JDBC_PREFIX + ":"); + else if (!dbUrl.startsWith(JDBCConnection.JDBC_PREFIX)) + throw new TAPException("JDBC URL format incorrect! It MUST begins with " + JDBCConnection.JDBC_PREFIX); else{ - String dbType = dbUrl.substring(JDBCConnection.JDBC_PREFIX.length() + 1); + String dbType = dbUrl.substring(JDBCConnection.JDBC_PREFIX.length()); if (dbType.indexOf(':') <= 0) throw new TAPException("JDBC URL format incorrect! Database type name is missing."); dbType = dbType.substring(0, dbType.indexOf(':')); diff --git a/src/tap/db/JDBCConnection.java b/src/tap/db/JDBCConnection.java index d65886f66a1d89ea63bbddf1beefca03723d5368..2f6e294da913b12f9dc79cd794f3b30c9f2ebf19 100644 --- a/src/tap/db/JDBCConnection.java +++ b/src/tap/db/JDBCConnection.java @@ -16,7 +16,7 @@ package tap.db; * You should have received a copy of the GNU Lesser General Public License * along with TAPLibrary. If not, see <http://www.gnu.org/licenses/>. * - * Copyright 2012-2016 - UDS/Centre de DonnĂ©es astronomiques de Strasbourg (CDS), + * Copyright 2012-2017 - UDS/Centre de DonnĂ©es astronomiques de Strasbourg (CDS), * Astronomisches Rechen Institut (ARI) */ @@ -177,7 +177,7 @@ import uws.service.log.UWSLog.LogLevel; * </i></p> * * @author Grégory Mantelet (CDS;ARI) - * @version 2.1 (09/2016) + * @version 2.1 (03/2017) * @since 2.0 */ public class JDBCConnection implements DBConnection { @@ -237,7 +237,7 @@ public class JDBCConnection implements DBConnection { /* JDBC URL MANAGEMENT */ /** JDBC prefix of any database URL (for instance: jdbc:postgresql://127.0.0.1/myDB or jdbc:postgresql:myDB). */ - public final static String JDBC_PREFIX = "jdbc"; + public final static String JDBC_PREFIX = "jdbc:"; /** Name (in lower-case) of the DBMS with which the connection is linked. */ protected final String dbms; @@ -391,8 +391,8 @@ public class JDBCConnection implements DBConnection { if (dbUrl == null) throw new DBException("Missing database URL!"); - if (!dbUrl.startsWith(JDBC_PREFIX + ":")) - throw new DBException("This DBConnection implementation is only able to deal with JDBC connection! (the DB URL must start with \"" + JDBC_PREFIX + ":\" ; given url: " + dbUrl + ")"); + if (!dbUrl.startsWith(JDBC_PREFIX)) + throw new DBException("This DBConnection implementation is only able to deal with JDBC connection! (the DB URL must start with \"" + JDBC_PREFIX + "\" ; given url: " + dbUrl + ")"); dbUrl = dbUrl.substring(5); int indSep = dbUrl.indexOf(':'); @@ -425,7 +425,7 @@ public class JDBCConnection implements DBConnection { // Select the JDBDC driver: Driver d; try{ - d = DriverManager.getDriver(dbUrl); + d = DriverManager.getDriver(url); }catch(SQLException e){ try{ // ...load it, if necessary: @@ -433,11 +433,11 @@ public class JDBCConnection implements DBConnection { throw new DBException("Missing JDBC driver path! Since the required JDBC driver is not yet loaded, this path is needed to load it."); Class.forName(driverPath); // ...and try again: - d = DriverManager.getDriver(dbUrl); + d = DriverManager.getDriver(url); }catch(ClassNotFoundException cnfe){ throw new DBException("Impossible to find the JDBC driver \"" + driverPath + "\" !", cnfe); }catch(SQLException se){ - throw new DBException("No suitable JDBC driver found for the database URL \"" + dbUrl + "\" and the driver path \"" + driverPath + "\"!", se); + throw new DBException("No suitable JDBC driver found for the database URL \"" + url + "\" and the driver path \"" + driverPath + "\"!", se); } }