Mercurial > hg > monetdb-java
changeset 100:64530632dc2a embedded
Added the directory property for the embedded connection again.
author | Pedro Ferreira <pedro.ferreira@monetdbsolutions.com> |
---|---|
date | Thu, 12 Jan 2017 16:51:06 +0100 (2017-01-12) |
parents | 1dcb51573c89 |
children | 551093abca52 |
files | src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java src/main/java/nl/cwi/monetdb/jdbc/MonetDriver.java.in |
diffstat | 2 files changed, 15 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java +++ b/src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java @@ -1113,7 +1113,7 @@ public abstract class MonetConnection ex if (name.equals("host") || name.equals("port") || name.equals("user") || name.equals("password") || name.equals("database") || name.equals("language") || name.equals("so_timeout") || name.equals("hash") || name.equals("treat_blob_as_binary") || name.equals("follow_redirects") || - name.equals("treat_clob_as_longvarchar") || name.equals("embedded")) { + name.equals("treat_clob_as_longvarchar") || name.equals("embedded") || name.equals("directory")) { conn_props.setProperty(name, value); } else { addWarning("setClientInfo: " + name + "is not a recognised property", "01M07");
--- a/src/main/java/nl/cwi/monetdb/jdbc/MonetDriver.java.in +++ b/src/main/java/nl/cwi/monetdb/jdbc/MonetDriver.java.in @@ -193,6 +193,11 @@ final public class MonetDriver implement prop.description = "Whether or not to use an embedded MonetDB connection"; props.add(prop); + prop = new DriverPropertyInfo("directory", ""); + prop.required = false; + prop.description = "Sets the directory to set the database in a embedded connection (Embedded connection only)"; + props.add(prop); + DriverPropertyInfo[] dpi = new DriverPropertyInfo[props.size()]; return props.toArray(dpi); } @@ -421,15 +426,19 @@ final public class MonetDriver implement if(isEmbedded) { //instantiate the connection try { + String directory = props.getProperty("directory"); + if (directory == null || directory.trim().isEmpty()) + throw new IllegalArgumentException("directory should not be null or empty"); + if(EmbeddedConnectionClass == null) { EmbeddedConnectionClass = Class.forName("nl.cwi.monetdb.embedded.jdbc.EmbeddedConnection"); + if(EmbeddedConnectionClass == null) { //if it's still null then there is a problem + throw new SQLException("EmbeddedConnection Class not found! Please load the MonetDBJavaEmbedded JAR!"); + } } - if(EmbeddedConnectionClass == null) { //if it's still null then there is a problem - throw new SQLException("EmbeddedConnection Class not found!"); - } res = (MonetConnection) EmbeddedConnectionClass - .getDeclaredConstructor(Properties.class, String.class, String.class) - .newInstance(props, hash, language); + .getDeclaredConstructor(Properties.class, String.class, String.class, String.class) + .newInstance(props, hash, language, directory); } catch (InvocationTargetException | InstantiationException | IllegalAccessException | NoSuchMethodException | ClassNotFoundException e) { throw new SQLException(e);