Author: rvesse
Date: Thu Apr 10 23:50:00 2014
New Revision: 1586511
URL: http://svn.apache.org/r1586511
Log:
Infrastructure to allow setting JDBC compatibility level on a per-query basic
(JENA-673)
Modified:
jena/trunk/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/results/JenaResultSet.java
jena/trunk/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/statements/JenaStatement.java
Modified:
jena/trunk/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/results/JenaResultSet.java
URL:
http://svn.apache.org/viewvc/jena/trunk/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/results/JenaResultSet.java?rev=1586511&r1=1586510&r2=1586511&view=diff
==============================================================================
---
jena/trunk/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/results/JenaResultSet.java
(original)
+++
jena/trunk/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/results/JenaResultSet.java
Thu Apr 10 23:50:00 2014
@@ -77,7 +77,7 @@ public abstract class JenaResultSet impl
throw new SQLException("Statement for a Result Set cannot be
null");
this.statement = statement;
this.compatibilityLevel = JdbcCompatibility
-
.normalizeLevel(this.statement.getJenaConnection().getJdbcCompatibilityLevel());
+ .normalizeLevel(this.statement.getJdbcCompatibilityLevel());
}
/**
Modified:
jena/trunk/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/statements/JenaStatement.java
URL:
http://svn.apache.org/viewvc/jena/trunk/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/statements/JenaStatement.java?rev=1586511&r1=1586510&r2=1586511&view=diff
==============================================================================
---
jena/trunk/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/statements/JenaStatement.java
(original)
+++
jena/trunk/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/statements/JenaStatement.java
Thu Apr 10 23:50:00 2014
@@ -31,6 +31,7 @@ import java.util.Queue;
import java.util.concurrent.TimeUnit;
import org.apache.jena.atlas.iterator.Iter;
+import org.apache.jena.jdbc.JdbcCompatibility;
import org.apache.jena.jdbc.connections.JenaConnection;
import org.apache.jena.jdbc.results.AskResults;
import org.apache.jena.jdbc.results.MaterializedSelectResults;
@@ -65,6 +66,7 @@ public abstract class JenaStatement impl
protected static final int DEFAULT_TRANSACTION_LEVEL =
JenaConnection.DEFAULT_ISOLATION_LEVEL;
protected static final int NO_LIMIT = 0;
protected static final int DEFAULT_TYPE = ResultSet.TYPE_FORWARD_ONLY;
+ protected static final int USE_CONNECTION_COMPATIBILITY =
Integer.MIN_VALUE;
private List<String> commands = new ArrayList<String>();
private SQLWarning warnings = null;
@@ -84,6 +86,7 @@ public abstract class JenaStatement impl
@SuppressWarnings("unused")
private boolean escapeProcessing = false;
private int timeout = NO_LIMIT;
+ private int compatibilityLevel = USE_CONNECTION_COMPATIBILITY;
/**
* Creates a new statement
@@ -145,6 +148,49 @@ public abstract class JenaStatement impl
return this.connection;
}
+ /**
+ * Gets the JDBC compatibility level that is in use, see
+ * {@link JdbcCompatibility} for explanations
+ * <p>
+ * By default this is set at the connection level and inherited, however
you
+ * may call {@link #setJdbcCompatibilityLevel(int)} to set the
compatibility
+ * level for this statement. This allows you to change the compatibility
+ * level on a per-query basis if so desired.
+ * </p>
+ *
+ * @return Compatibility level
+ */
+ public int getJdbcCompatibilityLevel() {
+ if (this.compatibilityLevel == USE_CONNECTION_COMPATIBILITY)
+ return this.connection.getJdbcCompatibilityLevel();
+ return this.compatibilityLevel;
+ }
+
+ /**
+ * Sets the JDBC compatibility level that is in use, see
+ * {@link JdbcCompatibility} for explanations.
+ * <p>
+ * By default this is set at the connection level and inherited, however
you
+ * may call {@link #setJdbcCompatibilityLevel(int)} to set the
compatibility
+ * level for this statement. This allows you to change the compatibility
+ * level on a per-query basis if so desired.
+ * </p>
+ * <p>
+ * Changing the level may not effect existing open objects, behaviour in
+ * this case will be implementation specific.
+ * </p>
+ *
+ * @param level
+ * Compatibility level
+ */
+ public void setJdbcCompatibilityLevel(int level) {
+ if (level == USE_CONNECTION_COMPATIBILITY) {
+ this.compatibilityLevel = USE_CONNECTION_COMPATIBILITY;
+ } else {
+ this.compatibilityLevel = JdbcCompatibility.normalizeLevel(level);
+ }
+ }
+
@Override
public boolean isWrapperFor(Class<?> iface) throws SQLException {
throw new SQLFeatureNotSupportedException();
@@ -849,7 +895,8 @@ public abstract class JenaStatement impl
@SuppressWarnings("javadoc")
public void closeOnCompletion() throws SQLException {
- // We don't support the JDBC 4.1 feature of closing statements
automatically
+ // We don't support the JDBC 4.1 feature of closing statements
+ // automatically
throw new SQLFeatureNotSupportedException();
}
}