Changeset: 477c4de0eda2 for monetdb-java
URL: https://dev.monetdb.org/hg/monetdb-java?cmd=changeset;node=477c4de0eda2
Modified Files:
pom.xml
src/main/java/nl/cwi/monetdb/jdbc/MonetDriver.java.in
src/main/java/nl/cwi/monetdb/mcl/connection/ControlCommands.java
src/main/java/nl/cwi/monetdb/mcl/connection/IMonetDBLanguage.java
src/main/java/nl/cwi/monetdb/mcl/connection/SenderThread.java
src/main/java/nl/cwi/monetdb/mcl/connection/helpers/BufferReallocator.java
src/main/java/nl/cwi/monetdb/mcl/connection/helpers/ChannelSecurity.java
src/main/java/nl/cwi/monetdb/mcl/connection/helpers/GregorianCalendarParser.java
src/main/java/nl/cwi/monetdb/mcl/connection/helpers/TimestampHelper.java
src/main/java/nl/cwi/monetdb/mcl/connection/mapi/AbstractSocket.java
src/main/java/nl/cwi/monetdb/mcl/connection/mapi/MapiConnection.java
src/main/java/nl/cwi/monetdb/mcl/connection/mapi/MapiLanguage.java
src/main/java/nl/cwi/monetdb/mcl/connection/mapi/OldMapiSocket.java
src/main/java/nl/cwi/monetdb/mcl/protocol/AbstractProtocol.java
src/main/java/nl/cwi/monetdb/mcl/protocol/ServerResponses.java
src/main/java/nl/cwi/monetdb/mcl/protocol/StarterHeaders.java
src/main/java/nl/cwi/monetdb/mcl/protocol/TableResultHeaders.java
src/main/java/nl/cwi/monetdb/mcl/protocol/oldmapi/OldMapiDataBlockResponse.java
src/main/java/nl/cwi/monetdb/mcl/protocol/oldmapi/OldMapiProtocol.java
src/main/java/nl/cwi/monetdb/mcl/protocol/oldmapi/OldMapiServerResponseParser.java
src/main/java/nl/cwi/monetdb/mcl/protocol/oldmapi/OldMapiStartOfHeaderParser.java
src/main/java/nl/cwi/monetdb/mcl/protocol/oldmapi/OldMapiTableHeaderParser.java
src/main/java/nl/cwi/monetdb/mcl/protocol/oldmapi/OldMapiTupleLineParser.java
src/main/java/nl/cwi/monetdb/mcl/protocol/oldmapi/OldMapiTupleLineParserHelper.java
src/main/java/nl/cwi/monetdb/mcl/responses/AbstractDataBlockResponse.java
src/main/java/nl/cwi/monetdb/mcl/responses/AutoCommitResponse.java
src/main/java/nl/cwi/monetdb/mcl/responses/IIncompleteResponse.java
src/main/java/nl/cwi/monetdb/mcl/responses/IResponse.java
src/main/java/nl/cwi/monetdb/mcl/responses/ResultSetResponse.java
src/main/java/nl/cwi/monetdb/mcl/responses/SchemaResponse.java
src/main/java/nl/cwi/monetdb/mcl/responses/UpdateResponse.java
Branch: embedded
Log Message:
Fixed identation and in-memory option for the embedded connection
diffs (truncated from 7816 to 300 lines):
diff --git a/pom.xml b/pom.xml
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
<groupId>monetdb</groupId>
<artifactId>monetdb-jdbc-new</artifactId>
- <version>2.31</version>
+ <version>2.32</version>
<name>MonetDB JDBC new</name>
<description>MonetDB Adapted JDBC driver for embedded
connection</description>
<url>https://www.monetdb.org</url>
diff --git a/src/main/java/nl/cwi/monetdb/jdbc/MonetDriver.java.in
b/src/main/java/nl/cwi/monetdb/jdbc/MonetDriver.java.in
--- a/src/main/java/nl/cwi/monetdb/jdbc/MonetDriver.java.in
+++ b/src/main/java/nl/cwi/monetdb/jdbc/MonetDriver.java.in
@@ -69,7 +69,7 @@ public final class MonetDriver implement
/** MonetDB default port to connect to */
private static final String PORT = "@JDBC_DEF_PORT@";
- private static Class embeddedConnectionClass = null;
+ private static Class embeddedConnectionClass = null;
// initialize this class: register it at the DriverManager
// Chapter 9.2 from Sun JDBC 3.0 specification
@@ -348,59 +348,59 @@ public final class MonetDriver implement
throw new SQLException("Invalid URL: it does not start
with: " + MONETURL, "08M26");
if(!url.startsWith("jdbc:monetdb:embedded:")) {
- // url should be of style jdbc:monetdb://<host>/<database>
- isEmbedded = false;
- URI uri;
- try {
- uri = new URI(url.substring(5));
- } catch (URISyntaxException e) {
- throw new SQLException(e.toString(), "08M26");
- }
+ // url should be of style
jdbc:monetdb://<host>/<database>
+ isEmbedded = false;
+ URI uri;
+ try {
+ uri = new URI(url.substring(5));
+ } catch (URISyntaxException e) {
+ throw new SQLException(e.toString(), "08M26");
+ }
- String uri_host = uri.getHost();
- if (uri_host == null)
- throw new SQLException("Invalid URL: no hostname given or
unparsable in '" + url + "'", "08M26");
- info.put("host", uri_host);
+ String uri_host = uri.getHost();
+ if (uri_host == null)
+ throw new SQLException("Invalid URL: no
hostname given or unparsable in '" + url + "'", "08M26");
+ info.put("host", uri_host);
- int uri_port = uri.getPort();
- if (uri_port > 0)
- info.put("port", "" + uri_port);
+ int uri_port = uri.getPort();
+ if (uri_port > 0)
+ info.put("port", "" + uri_port);
- // check the database
- String uri_path = uri.getPath();
- if (uri_path != null && uri_path.length() != 0) {
- uri_path = uri_path.substring(1);
- if (!uri_path.trim().isEmpty())
- info.put("database", uri_path);
- }
+ // check the database
+ String uri_path = uri.getPath();
+ if (uri_path != null && uri_path.length() != 0) {
+ uri_path = uri_path.substring(1);
+ if (!uri_path.trim().isEmpty())
+ info.put("database", uri_path);
+ }
- String uri_query = uri.getQuery();
- if (uri_query != null) {
- // handle additional arguments
- String args[] = uri_query.split("&");
- for (String arg : args) {
- tmp = arg.indexOf('=');
- if (tmp > 0)
- info.put(arg.substring(0, tmp), arg.substring(tmp +
1));
- }
- }
+ String uri_query = uri.getQuery();
+ if (uri_query != null) {
+ // handle additional arguments
+ String args[] = uri_query.split("&");
+ for (String arg : args) {
+ tmp = arg.indexOf('=');
+ if (tmp > 0)
+ info.put(arg.substring(0, tmp),
arg.substring(tmp + 1));
+ }
+ }
} else {
- // url should be of style jdbc:monetdb:embedded:<directory>
- isEmbedded = true;
- info.put("directory", url.substring(22));
+ // url should be of style
jdbc:monetdb:embedded:<directory>
+ isEmbedded = true;
+ info.put("directory", url.substring(22));
}
info.put("embedded", Boolean.toString(isEmbedded));
- // finally return the Connection as requested
+ // finally return the Connection as requested
return CreateMonetDBJDBCConnection(info);
}
- @SuppressWarnings("unchecked")
+ @SuppressWarnings("unchecked")
private static MonetConnection CreateMonetDBJDBCConnection(Properties
props) throws SQLException,
IllegalArgumentException {
MonetConnection res;
- boolean isEmbedded =
Boolean.parseBoolean(props.getProperty("embedded", "false"));
+ boolean isEmbedded =
Boolean.parseBoolean(props.getProperty("embedded", "false"));
String language = props.getProperty("language", "sql");
String username = props.getProperty("user");
String password = props.getProperty("password");
@@ -409,21 +409,20 @@ public final 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 is still
null then there is a problem!
- throw new SQLException("EmbeddedConnection Class not
found! Please add the MonetDBJavaEmbedded JAR to the Classpath!");
- }
- }
- res = (MonetConnection) embeddedConnectionClass
- .getDeclaredConstructor(Properties.class, String.class,
String.class, String.class)
- .newInstance(props, hash, language, directory);
+ String directory =
props.getProperty("directory");
+ if (directory != null &&
(directory.trim().isEmpty() || directory.equals(":memory:")))
+ directory = null;
+ if(embeddedConnectionClass == null) {
+ embeddedConnectionClass =
Class.forName("nl.cwi.monetdb.embedded.jdbc.EmbeddedConnection");
+ if(embeddedConnectionClass == null) {
//if it is still null then there is a problem!
+ throw new
SQLException("EmbeddedConnection Class not found! Please add monetdb-java-lite
jar to the CLASSPATH");
+ }
+ }
+ res = (MonetConnection) embeddedConnectionClass
+
.getDeclaredConstructor(Properties.class, String.class, String.class,
String.class)
+ .newInstance(props, hash, language,
directory);
} catch (InvocationTargetException |
InstantiationException | IllegalAccessException |
- NoSuchMethodException | ClassNotFoundException
e) {
+ NoSuchMethodException |
ClassNotFoundException e) {
throw new SQLException(e);
}
} else {
@@ -434,12 +433,12 @@ public final class MonetDriver implement
throw new IllegalArgumentException("user should
not be null or empty");
if (password == null || password.trim().isEmpty())
throw new IllegalArgumentException("password
should not be null or empty");
- String database = props.getProperty("database");
- if (database == null || database.trim().isEmpty())
- throw new IllegalArgumentException("database should not be
null or empty");
+ String database = props.getProperty("database");
+ if (database == null || database.trim().isEmpty())
+ throw new IllegalArgumentException("database
should not be null or empty");
- boolean blobIsBinary =
Boolean.valueOf(props.getProperty("treat_blob_as_binary", "false"));
- boolean clobIsLongChar =
Boolean.valueOf(props.getProperty("treat_clob_as_longvarchar", "false"));
+ boolean blobIsBinary =
Boolean.valueOf(props.getProperty("treat_blob_as_binary", "false"));
+ boolean clobIsLongChar =
Boolean.valueOf(props.getProperty("treat_clob_as_longvarchar", "false"));
boolean negative1 = false, failedparse1 = false;
int port = 0;
@@ -506,7 +505,7 @@ public final class MonetDriver implement
throw new SQLException("Unable to connect (" +
con.getHostname() + ":"
+ con.getPort() + "): " +
e.getMessage(), "08006");
} else {
- throw new SQLException("Unable to connect: " + e.getMessage(),
"08006");
+ throw new SQLException("Unable to connect: " +
e.getMessage(), "08006");
}
} catch (ProtocolException e) {
throw new SQLException(e.getMessage(), "08001");
diff --git a/src/main/java/nl/cwi/monetdb/mcl/connection/ControlCommands.java
b/src/main/java/nl/cwi/monetdb/mcl/connection/ControlCommands.java
--- a/src/main/java/nl/cwi/monetdb/mcl/connection/ControlCommands.java
+++ b/src/main/java/nl/cwi/monetdb/mcl/connection/ControlCommands.java
@@ -15,14 +15,14 @@ package nl.cwi.monetdb.mcl.connection;
*/
public final class ControlCommands {
- /* Please don't change the order or the values */
+ /* Please don't change the order or the values */
- /** Send autocommit statement */
- public static final int AUTO_COMMIT = 1;
- /** Set reply size for the server (for the maxrows specification) */
- public static final int REPLY_SIZE = 2;
- /** Release a prepared statement data */
- public static final int RELEASE = 3;
- /** Close a query */
- public static final int CLOSE = 4;
+ /** Send autocommit statement */
+ public static final int AUTO_COMMIT = 1;
+ /** Set reply size for the server (for the maxrows specification) */
+ public static final int REPLY_SIZE = 2;
+ /** Release a prepared statement data */
+ public static final int RELEASE = 3;
+ /** Close a query */
+ public static final int CLOSE = 4;
}
diff --git a/src/main/java/nl/cwi/monetdb/mcl/connection/IMonetDBLanguage.java
b/src/main/java/nl/cwi/monetdb/mcl/connection/IMonetDBLanguage.java
--- a/src/main/java/nl/cwi/monetdb/mcl/connection/IMonetDBLanguage.java
+++ b/src/main/java/nl/cwi/monetdb/mcl/connection/IMonetDBLanguage.java
@@ -16,40 +16,40 @@ package nl.cwi.monetdb.mcl.connection;
*/
public interface IMonetDBLanguage {
- /**
- * Gets the String representation of a query delimiter represented through
the index parameter.
- *
- * @param index The delimiter index starting from 0
- * @return The String representation of the delimiter
- */
- String getQueryTemplateIndex(int index);
+ /**
+ * Gets the String representation of a query delimiter represented
through the index parameter.
+ *
+ * @param index The delimiter index starting from 0
+ * @return The String representation of the delimiter
+ */
+ String getQueryTemplateIndex(int index);
- /**
- * Gets the String representation of a command delimiter represented
through the index parameter.
- *
- * @param index The delimiter index starting from 0
- * @return The String representation of the delimiter
- */
- String getCommandTemplateIndex(int index);
+ /**
+ * Gets the String representation of a command delimiter represented
through the index parameter.
+ *
+ * @param index The delimiter index starting from 0
+ * @return The String representation of the delimiter
+ */
+ String getCommandTemplateIndex(int index);
- /**
- * Gets all query delimiters.
- *
- * @return All query delimiters
- */
- String[] getQueryTemplates();
+ /**
+ * Gets all query delimiters.
+ *
+ * @return All query delimiters
+ */
+ String[] getQueryTemplates();
- /**
- * Gets all command delimiters.
- *
- * @return All command delimiters
- */
- String[] getCommandTemplates();
+ /**
+ * Gets all command delimiters.
+ *
+ * @return All command delimiters
+ */
+ String[] getCommandTemplates();
- /**
- * Gets the String representation of the language currently used.
- *
- * @return The String representation of the language currently used.
- */
- String getRepresentation();
+ /**
+ * Gets the String representation of the language currently used.
+ *
+ * @return The String representation of the language currently used.
+ */
+ String getRepresentation();
}
diff --git a/src/main/java/nl/cwi/monetdb/mcl/connection/SenderThread.java
b/src/main/java/nl/cwi/monetdb/mcl/connection/SenderThread.java
--- a/src/main/java/nl/cwi/monetdb/mcl/connection/SenderThread.java
+++ b/src/main/java/nl/cwi/monetdb/mcl/connection/SenderThread.java
@@ -27,121 +27,121 @@ import java.util.concurrent.locks.Reentr
*/
public class SenderThread extends Thread {
- /** The state WAIT represents this thread to be waiting for something to
do */
- private static final int WAIT = 1;
- /** The state QUERY represents this thread to be executing a query */
- private static final int QUERY = 2;
- /** The state SHUTDOWN is the final state that ends this thread */
- private static final int SHUTDOWN = 3;
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list