Changeset: 888db1607fa1 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=888db1607fa1
Modified Files:
java/src/nl/cwi/monetdb/jdbc/MonetPreparedStatementJavaImpl.java
Branch: headless
Log Message:
Merge with default branch.
diffs (truncated from 1446 to 300 lines):
diff --git a/common/utils/mutils.c b/common/utils/mutils.c
--- a/common/utils/mutils.c
+++ b/common/utils/mutils.c
@@ -28,6 +28,10 @@
#include "mutils.h"
+#ifdef HAVE_MACH_O_DYLD_H
+# include <mach-o/dyld.h> /* _NSGetExecutablePath on OSX >=10.5 */
+#endif
+
#ifdef NATIVE_WIN32
#include <stdio.h>
@@ -311,3 +315,40 @@
printf("back traces are not supported on this platform\n");
}
#endif
+
+static char _bin_path[1024];
+char *
+get_bin_path(void)
+{
+ /* getting the path to the executable's binary, isn't all that
+ * simple, unfortunately */
+#if defined(_MSC_VER) /* Windows */
+ if (GetModuleFileName(NULL, _bin_path,
+ (DWORD) sizeof(_bin_path)) != 0)
+ return _bin_path;
+#elif defined(HAVE__NSGETEXECUTABLEPATH) /* Darwin/OSX */
+ uint32_t size = sizeof(_bin_path);
+ if (_NSGetExecutablePath(_bin_path, &size) == 0)
+ return _bin_path;
+#elif defined(HAVE_SYS_SYSCTL_H) && defined(KERN_PROC_PATHNAME) /* BSD */
+ int mib[4];
+ size_t cb = sizeof(_bin_path);
+ mib[0] = CTL_KERN;
+ mib[1] = KERN_PROC;
+ mib[2] = KERN_PROC_PATHNAME;
+ mib[3] = -1;
+ if (sysctl(mib, 4, _bin_path, &cb, NULL, 0) == 0)
+ return _bin_path;
+#elif defined(HAVE_GETEXECNAME) /* Solaris */
+ const char *execn = getexecname();
+ /* copy, such that the caller can actually modify this string */
+ snprintf(_bin_path, sizeof(_bin_path), "%s", execn);
+ return _bin_path;
+#else /* try Linux approach */
+ if (readlink("/proc/self/exe",
+ _bin_path, sizeof(_bin_path)) != -1)
+ return _bin_path;
+#endif
+ /* could use argv[0] (passed) to deduce location based on PATH */
+ return NULL;
+}
diff --git a/common/utils/mutils.h b/common/utils/mutils.h
--- a/common/utils/mutils.h
+++ b/common/utils/mutils.h
@@ -73,5 +73,6 @@
mutils_export int MT_lockf(char *filename, int mode, off_t off, off_t len);
mutils_export void print_trace(void);
+mutils_export char *get_bin_path(void);
#endif /* _MUTILS_H_ */
diff --git a/java/ChangeLog b/java/ChangeLog
--- a/java/ChangeLog
+++ b/java/ChangeLog
@@ -1,3 +1,7 @@
# ChangeLog file for java
# This file is updated with Maddlog
+* Mon Apr 11 2011 Fabian Groffen <[email protected]>
+- The obsolete Java-based implementation for PreparedStatements (formerly
+ activated using the java_prepared_statements property) has been dropped
+
diff --git a/java/src/nl/cwi/monetdb/jdbc/MonetConnection.java
b/java/src/nl/cwi/monetdb/jdbc/MonetConnection.java
--- a/java/src/nl/cwi/monetdb/jdbc/MonetConnection.java
+++ b/java/src/nl/cwi/monetdb/jdbc/MonetConnection.java
@@ -115,9 +115,6 @@
/** Embedded properties */
private static Properties embeddedProps = null;
- /** Whether or not to use a Java based PreparedStatement
- * implementation */
- private final boolean javaPreparedStatements;
/** Whether or not BLOB is mapped to BINARY within the driver */
private final boolean blobIsBinary;
@@ -148,7 +145,6 @@
this.database = props.getProperty("database");
this.username = props.getProperty("user");
this.password = props.getProperty("password");
- this.javaPreparedStatements =
Boolean.valueOf(props.getProperty("java_prepared_statements")).booleanValue();
String language = props.getProperty("language");
boolean debug =
Boolean.valueOf(props.getProperty("debug")).booleanValue();
String hash = props.getProperty("hash");
@@ -683,22 +679,13 @@
throws SQLException
{
try {
- PreparedStatement ret;
- if (!javaPreparedStatements) {
- // use a server-side PreparedStatement
- ret = new MonetPreparedStatement(
- this,
- resultSetType,
- resultSetConcurrency,
- resultSetHoldability,
- sql
- );
- } else {
- // use a Java implementation of a
PreparedStatement
- ret = new MonetPreparedStatementJavaImpl(
- this, resultSetType,
resultSetConcurrency, sql
- );
- }
+ PreparedStatement ret = new MonetPreparedStatement(
+ this,
+ resultSetType,
+ resultSetConcurrency,
+ resultSetHoldability,
+ sql
+ );
// store it in the map for when we close...
statements.put(ret, null);
return(ret);
diff --git a/java/src/nl/cwi/monetdb/jdbc/MonetDriver.java.in
b/java/src/nl/cwi/monetdb/jdbc/MonetDriver.java.in
--- a/java/src/nl/cwi/monetdb/jdbc/MonetDriver.java.in
+++ b/java/src/nl/cwi/monetdb/jdbc/MonetDriver.java.in
@@ -117,7 +117,6 @@
props.put("port", PORT);
props.put("debug", "false");
props.put("language", "sql"); // mal, sql, <future>
- props.put("java_prepared_statements", "false");
props.putAll(info);
info = props;
@@ -230,11 +229,6 @@
prop.description = "Force the use of the given hash algorithm
during challenge response (one of SHA1, MD5, plain)";
props.add(prop);
- prop = new DriverPropertyInfo("java_prepared_statements",
"false");
- prop.required = false;
- prop.description = "Whether Java emulated prepared statements
(true) or a server side prepated statements (false) should be used";
- props.add(prop);
-
prop = new DriverPropertyInfo("follow_redirects", "true");
prop.required = false;
prop.description = "Whether redirects issued by the server
should be followed";
diff --git a/java/src/nl/cwi/monetdb/jdbc/MonetPreparedStatementJavaImpl.java
b/java/src/nl/cwi/monetdb/jdbc/MonetPreparedStatementJavaImpl.java
deleted file mode 100644
--- a/java/src/nl/cwi/monetdb/jdbc/MonetPreparedStatementJavaImpl.java
+++ /dev/null
@@ -1,366 +0,0 @@
-/*
- * The contents of this file are subject to the MonetDB Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://monetdb.cwi.nl/Legal/MonetDBLicense-1.1.html
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
- * License for the specific language governing rights and limitations
- * under the License.
- *
- * The Original Code is the MonetDB Database System.
- *
- * The Initial Developer of the Original Code is CWI.
- * Portions created by CWI are Copyright (C) 1997-July 2008 CWI.
- * Copyright August 2008-2011 MonetDB B.V.
- * All Rights Reserved.
- */
-
-package nl.cwi.monetdb.jdbc;
-
-import java.sql.*;
-import java.util.*;
-import java.net.URL;
-import java.io.*;
-import java.math.*; // BigDecimal, etc.
-
-/**
- * A PreparedStatement suitable for the MonetDB database implemented in
- * Java.
- * <br /><br />
- * Although this class is deprecated, and has been replaced by an
- * implementation that makes use of server side capabilities, this class
- * is still provided for users that somehow rely on the behaviours from
- * this Java implementation of a PreparedStatement.
- * <br /><br />
- * This implementation is purely for enabling applications to use the
- * interface PreparedStatement, for it does currently not use a PREPARE
- * call on the MonetDB SQL backend.
- * <br /><br />
- * Because we have no DBMS support here, we need to fake the lot to make
- * it work. We try to spot `?', when not enclosed by single or double
- * quotes. The positions of the question marks will later be replaced
- * by the appropriate SQL and sent to the server using the underlying
- * Statement.
- *
- * @author Fabian Groffen <[email protected]>
- * @version 0.3
- * @deprecated
- */
-public class MonetPreparedStatementJavaImpl
- extends MonetPreparedStatement
-{
- private final String pQuery;
-
- private final int size;
- private final int[] pos;
- private final String[] value;
-
- /**
- * Constructor which checks the arguments for validity. This
- * constructor is only accessible to classes from the jdbc package.
- *
- * @param connection the connection that created this Statement
- * @param resultSetType type of ResultSet to produce
- * @param resultSetConcurrency concurrency of ResultSet to produce
- * @throws SQLException if an error occurs during login
- * @throws IllegalArgumentException is one of the arguments is null or
empty
- */
- MonetPreparedStatementJavaImpl(
- MonetConnection connection,
- int resultSetType,
- int resultSetConcurrency,
- String prepareQuery)
- throws SQLException, IllegalArgumentException
- {
- super(
- connection,
- resultSetType,
- resultSetConcurrency,
- ResultSet.HOLD_CURSORS_OVER_COMMIT
- );
-
- pQuery = prepareQuery;
-
- // find qualifying ?'s
- List tpos = new ArrayList();
-
- boolean inString = false;
- boolean inIdentifier = false;
- boolean escaped = false;
- int len = pQuery.length();
- for (int i = 0; i < len; i++) {
- switch(pQuery.charAt(i)) {
- case '\\':
- escaped = !escaped;
- break;
- default:
- escaped = false;
- break;
- case '\'':
- /**
- * We can not be in a string if we are
in an identifier. So
- * If we find a ' and are not in an
identifier, and not in
- * a string we can safely assume we
will be now in a string.
- * If we are in a string already, we
should stop being in a
- * string if we find a quote which is
not prefixed by a \,
- * for that would be an escaped quote.
However, a nasty
- * situation can occur where the string
is like 'test \\'.
- * As obvious, a test for a \ in front
of a ' doesn't hold
- * here. Because 'test \\\'' can exist
as well, we need to
- * know if a quote is prefixed by an
escaping slash or not.
- */
- if (!inIdentifier) {
- if (!inString && !escaped) {
- // although it makes no
sense to escape a quote
- // outside a string, it
is escaped, thus not meant
- // as quote for us,
apparently
- inString = true;
- } else if (inString &&
!escaped) {
- inString = false;
- }
- } else {
- // reset escaped flag
- escaped = false;
- }
- break;
- case '"':
- if (!inString) {
- if (!inIdentifier && !escaped) {
- inIdentifier = true;
- } else if (inIdentifier &&
!escaped) {
- inIdentifier = false;
- }
- } else {
- // reset escaped flag
- escaped = false;
- }
- break;
- case '-':
- if (!escaped && !(inString ||
inIdentifier) && i + 1 < len && pQuery.charAt(i + 1) == '-') {
- int nl = pQuery.indexOf('\n', i
+ 1);
- if (nl == -1) {
- // no newline found, so
we don't need to skip and
- // can stop right away
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list