You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by ka...@apache.org on 2012/07/17 11:08:08 UTC
svn commit: r1362419 - in /db/derby/code/trunk/java/client: ./
org/apache/derby/client/ org/apache/derby/client/am/
org/apache/derby/client/am/stmtcache/ org/apache/derby/client/net/
org/apache/derby/jdbc/
Author: kahatlen
Date: Tue Jul 17 09:08:07 2012
New Revision: 1362419
URL: http://svn.apache.org/viewvc?rev=1362419&view=rev
Log:
DERBY-5840: Compile network client with source and target level 1.5
Modified:
db/derby/code/trunk/java/client/build.xml
db/derby/code/trunk/java/client/org/apache/derby/client/ClientPooledConnection.java
db/derby/code/trunk/java/client/org/apache/derby/client/am/ByteArrayCombinerStream.java
db/derby/code/trunk/java/client/org/apache/derby/client/am/ColumnMetaData.java
db/derby/code/trunk/java/client/org/apache/derby/client/am/Configuration.java
db/derby/code/trunk/java/client/org/apache/derby/client/am/Connection.java
db/derby/code/trunk/java/client/org/apache/derby/client/am/Cursor.java
db/derby/code/trunk/java/client/org/apache/derby/client/am/Lob.java
db/derby/code/trunk/java/client/org/apache/derby/client/am/LogWriter.java
db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalCallableStatement.java
db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalConnection.java
db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalConnection40.java
db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement.java
db/derby/code/trunk/java/client/org/apache/derby/client/am/ResultSet.java
db/derby/code/trunk/java/client/org/apache/derby/client/am/SectionManager.java
db/derby/code/trunk/java/client/org/apache/derby/client/am/Statement.java
db/derby/code/trunk/java/client/org/apache/derby/client/am/StatementCacheInteractor.java
db/derby/code/trunk/java/client/org/apache/derby/client/am/stmtcache/JDBCStatementCache.java
db/derby/code/trunk/java/client/org/apache/derby/client/net/CodePointNameTable.java
db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConnection40.java
db/derby/code/trunk/java/client/org/apache/derby/client/net/NetCursor.java
db/derby/code/trunk/java/client/org/apache/derby/client/net/NetStatementReply.java
db/derby/code/trunk/java/client/org/apache/derby/client/net/NetStatementRequest.java
db/derby/code/trunk/java/client/org/apache/derby/client/net/NetXAConnectionReply.java
db/derby/code/trunk/java/client/org/apache/derby/client/net/NetXAResource.java
db/derby/code/trunk/java/client/org/apache/derby/client/net/OpenSocketAction.java
db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientBaseDataSource.java
Modified: db/derby/code/trunk/java/client/build.xml
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/build.xml?rev=1362419&r1=1362418&r2=1362419&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/build.xml (original)
+++ db/derby/code/trunk/java/client/build.xml Tue Jul 17 09:08:07 2012
@@ -50,8 +50,8 @@
<!-- compile classes -->
<target name="compile">
<javac
- source="1.4"
- target="1.4"
+ source="1.5"
+ target="1.5"
bootclasspath="${empty}"
nowarn="on"
debug="${debug}"
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/ClientPooledConnection.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/ClientPooledConnection.java?rev=1362419&r1=1362418&r2=1362419&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/ClientPooledConnection.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/ClientPooledConnection.java Tue Jul 17 09:08:07 2012
@@ -22,18 +22,18 @@ package org.apache.derby.client;
import java.sql.PreparedStatement;
import java.sql.SQLException;
-import javax.sql.ConnectionEvent;
-import javax.sql.ConnectionEventListener;
import java.util.ArrayList;
import java.util.Iterator;
-import org.apache.derby.client.net.NetXAConnection;
-import org.apache.derby.iapi.error.ExceptionSeverity;
-import org.apache.derby.jdbc.ClientBaseDataSource;
-import org.apache.derby.jdbc.ClientDriver;
+import javax.sql.ConnectionEvent;
+import javax.sql.ConnectionEventListener;
import org.apache.derby.client.am.ClientMessageId;
import org.apache.derby.client.am.SqlException;
import org.apache.derby.client.am.stmtcache.JDBCStatementCache;
import org.apache.derby.client.net.NetLogWriter;
+import org.apache.derby.client.net.NetXAConnection;
+import org.apache.derby.iapi.error.ExceptionSeverity;
+import org.apache.derby.jdbc.ClientBaseDataSource;
+import org.apache.derby.jdbc.ClientDriver;
import org.apache.derby.shared.common.reference.SQLState;
/**
@@ -47,7 +47,8 @@ public class ClientPooledConnection impl
//@GuardedBy("this")
/** List of {@code ConnectionEventListener}s. Never {@code null}. */
- private ArrayList listeners_ = new ArrayList();
+ private ArrayList<ConnectionEventListener> listeners_ =
+ new ArrayList<ConnectionEventListener>();
/**
* The number of iterators going through the list of connection event
@@ -323,7 +324,7 @@ public class ClientPooledConnection impl
// we were able to synchronize on this, that someone is us. Clone
// the list of listeners in order to prevent invalidation of the
// iterator.
- listeners_ = (ArrayList) listeners_.clone();
+ listeners_ = new ArrayList<ConnectionEventListener>(listeners_);
}
listeners_.add(listener);
}
@@ -338,7 +339,7 @@ public class ClientPooledConnection impl
// we were able to synchronize on this, that someone is us. Clone
// the list of listeners in order to prevent invalidation of the
// iterator.
- listeners_ = (ArrayList) listeners_.clone();
+ listeners_ = new ArrayList<ConnectionEventListener>(listeners_);
}
listeners_.remove(listener);
}
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/ByteArrayCombinerStream.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/ByteArrayCombinerStream.java?rev=1362419&r1=1362418&r2=1362419&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/ByteArrayCombinerStream.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/ByteArrayCombinerStream.java Tue Jul 17 09:08:07 2012
@@ -47,7 +47,7 @@ public class ByteArrayCombinerStream
extends InputStream {
/** A list of the arrays to combine. */
- private final ArrayList arrays;
+ private final ArrayList<byte[]> arrays;
/** Length of the stream. */
private final long specifiedLength;
/** Global offset into the whole stream. */
@@ -72,7 +72,7 @@ public class ByteArrayCombinerStream
* specified by <code>length</code>, or <code>length</code> is
* negative.
*/
- public ByteArrayCombinerStream(ArrayList arraysIn, long length) {
+ public ByteArrayCombinerStream(ArrayList<byte[]> arraysIn, long length) {
// Don't allow negative length.
if (length < 0) {
throw new IllegalArgumentException("Length cannot be negative: " +
@@ -84,11 +84,11 @@ public class ByteArrayCombinerStream
// Copy references to the byte arrays to a new ArrayList.
int arrayCount = arraysIn.size();
byte[] tmpArray;
- arrays = new ArrayList(arrayCount);
+ arrays = new ArrayList<byte[]>(arrayCount);
// Truncate data if there are more bytes then specified.
// Done to simplify boundary checking in the read-methods.
for (int i=0; i < arrayCount && tmpRemaining > 0; i++) {
- tmpArray = (byte[])arraysIn.get(i);
+ tmpArray = arraysIn.get(i);
if (tmpRemaining < tmpArray.length) {
// Create a new shrunk array.
byte[] shrunkArray =
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/ColumnMetaData.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/ColumnMetaData.java?rev=1362419&r1=1362418&r2=1362419&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/ColumnMetaData.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/ColumnMetaData.java Tue Jul 17 09:08:07 2012
@@ -22,7 +22,7 @@
package org.apache.derby.client.am;
import java.sql.SQLException;
-
+import java.util.Hashtable;
import org.apache.derby.iapi.reference.DRDAConstants;
import org.apache.derby.iapi.reference.JDBC30Translation;
import org.apache.derby.shared.common.reference.SQLState;
@@ -98,7 +98,7 @@ public class ColumnMetaData implements j
public transient int resultSetConcurrency_;
- transient private java.util.Hashtable columnNameToIndexCache_ = null;
+ transient private Hashtable<String, Integer> columnNameToIndexCache_;
transient private boolean statementClosed_ = false;
@@ -805,9 +805,9 @@ public class ColumnMetaData implements j
int findColumnX(String columnName) throws SqlException {
// Create cache if it doesn't exist
if (columnNameToIndexCache_ == null) {
- columnNameToIndexCache_ = new java.util.Hashtable();
+ columnNameToIndexCache_ = new Hashtable<String, Integer>();
} else { // Check cache for mapping
- Integer index = (Integer) columnNameToIndexCache_.get(columnName);
+ Integer index = columnNameToIndexCache_.get(columnName);
if (index != null) {
return index.intValue();
}
@@ -819,7 +819,7 @@ public class ColumnMetaData implements j
this.sqlName_[col] != null &&
this.sqlName_[col].equalsIgnoreCase(columnName)) {
// Found it, add it to the cache
- columnNameToIndexCache_.put(columnName, new Integer(col + 1));
+ columnNameToIndexCache_.put(columnName, col + 1);
return col + 1;
}
}
@@ -830,10 +830,10 @@ public class ColumnMetaData implements j
// assign ordinal position as the column name if null.
void assignColumnName(int column) {
if (columnNameToIndexCache_ == null) {
- columnNameToIndexCache_ = new java.util.Hashtable();
+ columnNameToIndexCache_ = new Hashtable<String, Integer>();
}
- String columnName = (new Integer(column)).toString();
- columnNameToIndexCache_.put(columnName, new Integer(column));
+ String columnName = Integer.toString(column);
+ columnNameToIndexCache_.put(columnName, column);
sqlName_[column - 1] = columnName;
}
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/Configuration.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/Configuration.java?rev=1362419&r1=1362418&r2=1362419&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/Configuration.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/Configuration.java Tue Jul 17 09:08:07 2012
@@ -194,10 +194,10 @@ public class Configuration {
private static ProductVersionHolder buildProductVersionHolder() throws
java.security.PrivilegedActionException, IOException {
ProductVersionHolder myPVH = null;
- myPVH = (ProductVersionHolder)
- AccessController.doPrivileged(new PrivilegedExceptionAction() {
+ myPVH = AccessController.doPrivileged(
+ new PrivilegedExceptionAction<ProductVersionHolder>() {
- public Object run() throws IOException {
+ public ProductVersionHolder run() throws IOException {
InputStream versionStream = getClass().getResourceAsStream(ProductGenusNames.DNC_INFO);
return ProductVersionHolder.getProductVersionHolderFromMyEnv(versionStream);
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/Connection.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/Connection.java?rev=1362419&r1=1362418&r2=1362419&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/Connection.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/Connection.java Tue Jul 17 09:08:07 2012
@@ -21,13 +21,17 @@
package org.apache.derby.client.am;
-import org.apache.derby.jdbc.ClientBaseDataSource;
-import org.apache.derby.jdbc.ClientDataSource;
-import org.apache.derby.shared.common.reference.SQLState;
-
import java.sql.SQLException;
import java.util.Collections;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.WeakHashMap;
import org.apache.derby.client.net.NetXAResource;
+import org.apache.derby.jdbc.ClientBaseDataSource;
+import org.apache.derby.jdbc.ClientDataSource;
+import org.apache.derby.shared.common.reference.SQLState;
import org.apache.derby.shared.common.sanity.SanityManager;
public abstract class Connection
@@ -47,7 +51,8 @@ public abstract class Connection
// In Connection.markStatementsClosed() method, this list is traversed to get a
// list of open statements, which are marked closed and removed from the list.
- final java.util.WeakHashMap openStatements_ = new java.util.WeakHashMap();
+ final WeakHashMap<Statement, Void> openStatements_ =
+ new WeakHashMap<Statement, Void>();
// Some statuses of DERBY objects may be invalid on server
// after both commit and rollback. For example,
@@ -55,7 +60,9 @@ public abstract class Connection
// after both commit and rollback
// (2) result set will be unpositioned on server after both commit and rollback.
// If they depend on both commit and rollback, they need to get on CommitAndRollbackListeners_.
- final java.util.WeakHashMap CommitAndRollbackListeners_ = new java.util.WeakHashMap();
+ final WeakHashMap<UnitOfWorkListener, Void> CommitAndRollbackListeners_ =
+ new WeakHashMap<UnitOfWorkListener, Void>();
+
private SqlWarning warnings_ = null;
//Constant representing an invalid locator value
@@ -168,7 +175,9 @@ public abstract class Connection
public int portNumber_;
public int clientSSLMode_ = ClientBaseDataSource.SSL_OFF;
- java.util.Hashtable clientCursorNameCache_ = new java.util.Hashtable();
+ Hashtable<String, String> clientCursorNameCache_ =
+ new Hashtable<String, String>();
+
public int commBufferSize_ = 32767;
// indicates if a deferred reset connection is required
@@ -868,25 +877,25 @@ public abstract class Connection
}
private void markStatementsClosed() {
- java.util.Set keySet = openStatements_.keySet();
- for (java.util.Iterator i = keySet.iterator(); i.hasNext();) {
- Statement stmt = (Statement) i.next();
+ Set<Statement> keySet = openStatements_.keySet();
+ for (Iterator<Statement> i = keySet.iterator(); i.hasNext();) {
+ Statement stmt = i.next();
stmt.markClosed();
i.remove();
}
}
private void writeCloseStatements() throws SqlException {
- java.util.Set keySet = openStatements_.keySet();
- for (java.util.Iterator i = keySet.iterator(); i.hasNext();) {
- ((Statement) i.next()).writeClose(false); // false means don't permit auto-commits
+ Set<Statement> keySet = openStatements_.keySet();
+ for (Iterator<Statement> i = keySet.iterator(); i.hasNext();) {
+ i.next().writeClose(false); // false means don't permit auto-commits
}
}
private void readCloseStatements() throws SqlException {
- java.util.Set keySet = openStatements_.keySet();
- for (java.util.Iterator i = keySet.iterator(); i.hasNext();) {
- ((Statement) i.next()).readClose(false); // false means don't permit auto-commits
+ Set<Statement> keySet = openStatements_.keySet();
+ for (Iterator<Statement> i = keySet.iterator(); i.hasNext();) {
+ i.next().readClose(false); // false means don't permit auto-commits
}
}
@@ -1401,14 +1410,14 @@ public abstract class Connection
return resultSetType;
}
- public java.util.Map getTypeMap() throws SQLException {
+ public Map<String, Class<?>> getTypeMap() throws SQLException {
try
{
if (agent_.loggingEnabled()) {
agent_.logWriter_.traceEntry(this, "getTypeMap");
}
checkForClosedConnection();
- java.util.Map map = Collections.EMPTY_MAP;
+ Map<String, Class<?>> map = Collections.emptyMap();
if (agent_.loggingEnabled()) {
agent_.logWriter_.traceExit(this, "getTypeMap", map);
}
@@ -1420,7 +1429,7 @@ public abstract class Connection
}
}
- synchronized public void setTypeMap(java.util.Map map) throws SQLException {
+ synchronized public void setTypeMap(Map map) throws SQLException {
try
{
if (agent_.loggingEnabled()) {
@@ -2024,10 +2033,9 @@ public abstract class Connection
throws SqlException;
public void completeLocalCommit() {
- java.util.Set keySet = CommitAndRollbackListeners_.keySet();
- for (java.util.Iterator i = keySet.iterator(); i.hasNext();) {
- UnitOfWorkListener listener = (UnitOfWorkListener) i.next();
- listener.completeLocalCommit(i);
+ Set<UnitOfWorkListener> keySet = CommitAndRollbackListeners_.keySet();
+ for (Iterator<UnitOfWorkListener> i = keySet.iterator(); i.hasNext();) {
+ i.next().completeLocalCommit(i);
}
inUnitOfWork_ = false;
transactionID_++;
@@ -2041,10 +2049,9 @@ public abstract class Connection
// This is a client-side only operation.
// This method will only throw an exception on bug check.
public void completeLocalRollback() {
- java.util.Set keySet = CommitAndRollbackListeners_.keySet();
- for (java.util.Iterator i = keySet.iterator(); i.hasNext();) {
- UnitOfWorkListener listener = (UnitOfWorkListener) i.next();
- listener.completeLocalRollback(i);
+ Set<UnitOfWorkListener> keySet = CommitAndRollbackListeners_.keySet();
+ for (Iterator<UnitOfWorkListener> i = keySet.iterator(); i.hasNext();) {
+ i.next().completeLocalRollback(i);
}
inUnitOfWork_ = false;
transactionID_++;
@@ -2057,9 +2064,9 @@ public abstract class Connection
*
*/
public void completeSpecificRollback(UnitOfWorkListener uwl) {
- java.util.Set keySet = CommitAndRollbackListeners_.keySet();
- for (java.util.Iterator i = keySet.iterator(); i.hasNext();) {
- UnitOfWorkListener listener = (UnitOfWorkListener) i.next();
+ Set<UnitOfWorkListener> keySet = CommitAndRollbackListeners_.keySet();
+ for (Iterator<UnitOfWorkListener> i = keySet.iterator(); i.hasNext();) {
+ UnitOfWorkListener listener = i.next();
if(listener == uwl) {
listener.completeLocalRollback(i);
break;
@@ -2237,10 +2244,8 @@ public abstract class Connection
// Iterate through the physical statements and re-enable them for reuse.
if (closeStatementsOnClose) {
- java.util.Set keySet = openStatements_.keySet();
- for (java.util.Iterator i = keySet.iterator(); i.hasNext();) {
- Object o = i.next();
- ((Statement) o).reset(closeStatementsOnClose);
+ for (Statement stmt : openStatements_.keySet()) {
+ stmt.reset(closeStatementsOnClose);
}
}
// Must reset transaction isolation level if it has been changed,
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/Cursor.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/Cursor.java?rev=1362419&r1=1362418&r2=1362419&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/Cursor.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/Cursor.java Tue Jul 17 09:08:07 2012
@@ -30,6 +30,7 @@ import java.io.ObjectInputStream;
import java.io.UnsupportedEncodingException;
import java.sql.Date;
import java.sql.Time;
+import java.util.ArrayList;
import java.util.Calendar;
// When we calculate column offsets make sure we calculate the correct offsets for double byte charactr5er data
@@ -88,19 +89,19 @@ public abstract class Cursor {
// Row positioning for all cached rows
// For scrollable result sets, these lists hold the offsets into the cached rowset buffer for each row of data.
- protected java.util.ArrayList columnDataPositionCache_ = new java.util.ArrayList();
- protected java.util.ArrayList columnDataLengthCache_ = new java.util.ArrayList();
- protected java.util.ArrayList columnDataIsNullCache_ = new java.util.ArrayList();
- public java.util.ArrayList isUpdateDeleteHoleCache_ = new java.util.ArrayList();
- public boolean isUpdateDeleteHole_;
+ protected ArrayList<int[]> columnDataPositionCache_ = new ArrayList<int[]>();
+ protected ArrayList<int[]> columnDataLengthCache_ = new ArrayList<int[]>();
+ protected ArrayList<boolean[]> columnDataIsNullCache_ = new ArrayList<boolean[]>();
+ ArrayList<Boolean> isUpdateDeleteHoleCache_ = new ArrayList<Boolean>();
+ boolean isUpdateDeleteHole_;
// State to keep track of when a row has been updated,
// cf. corresponding set and get accessors. Only implemented for
// scrollable updatable insensitive result sets for now.
private boolean isRowUpdated_;
- final static public java.lang.Boolean ROW_IS_NULL = new Boolean(true);
- final static public java.lang.Boolean ROW_IS_NOT_NULL = new Boolean(false);
+ final static Boolean ROW_IS_NULL = Boolean.TRUE;
+ final static Boolean ROW_IS_NOT_NULL = Boolean.FALSE;
java.util.Calendar recyclableCalendar_ = null;
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/Lob.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/Lob.java?rev=1362419&r1=1362418&r2=1362419&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/Lob.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/Lob.java Tue Jul 17 09:08:07 2012
@@ -204,7 +204,7 @@ public abstract class Lob implements Uni
protected InputStream materializeStream(InputStream is, String typeDesc)
throws SqlException {
final int GROWBY = 32 * 1024; // 32 KB
- ArrayList byteArrays = new ArrayList();
+ ArrayList<byte[]> byteArrays = new ArrayList<byte[]>();
byte[] curBytes = new byte[GROWBY];
int totalLength = 0;
int partLength = 0;
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/LogWriter.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/LogWriter.java?rev=1362419&r1=1362418&r2=1362419&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/LogWriter.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/LogWriter.java Tue Jul 17 09:08:07 2012
@@ -21,17 +21,17 @@
package org.apache.derby.client.am;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.security.AccessController;
+import java.security.PrivilegedExceptionAction;
import java.sql.SQLException;
import java.util.Enumeration;
import java.util.Properties;
-import java.security.AccessController;
-
import javax.naming.NamingException;
import javax.naming.RefAddr;
import javax.naming.Reference;
-
import org.apache.derby.jdbc.ClientBaseDataSource;
-
import org.apache.derby.jdbc.ClientDataSource;
import org.apache.derby.shared.common.reference.Attribute;
import org.apache.derby.shared.common.reference.SQLState;
@@ -1225,9 +1225,9 @@ public class LogWriter {
//do the work related to PrintWriter in it's run method and return
//PrintWriter object.
try {
- printWriter = (java.io.PrintWriter)AccessController.doPrivileged(
- new java.security.PrivilegedExceptionAction(){
- public Object run()throws java.io.IOException{
+ printWriter = AccessController.doPrivileged(
+ new PrivilegedExceptionAction<PrintWriter>(){
+ public PrintWriter run() throws IOException {
String fileCanonicalPath = new java.io.File(fileName).getCanonicalPath();
return new java.io.PrintWriter(
new java.io.BufferedOutputStream(
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalCallableStatement.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalCallableStatement.java?rev=1362419&r1=1362418&r2=1362419&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalCallableStatement.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalCallableStatement.java Tue Jul 17 09:08:07 2012
@@ -267,7 +267,7 @@ public class LogicalCallableStatement
getPhysCs().setObject(parameterName, x, targetSqlType, scale);
}
- public Object getObject(int i, Map map) throws SQLException {
+ public Object getObject(int i, Map<String, Class<?>> map) throws SQLException {
return getPhysCs().getObject(i, map);
}
@@ -355,7 +355,7 @@ public class LogicalCallableStatement
return getPhysCs().getTimestamp(parameterIndex, cal);
}
- public Object getObject(String parameterName, Map map) throws SQLException {
+ public Object getObject(String parameterName, Map<String, Class<?>> map) throws SQLException {
return getPhysCs().getObject(parameterName, map);
}
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalConnection.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalConnection.java?rev=1362419&r1=1362418&r2=1362419&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalConnection.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalConnection.java Tue Jul 17 09:08:07 2012
@@ -20,9 +20,10 @@
*/
package org.apache.derby.client.am;
-import org.apache.derby.shared.common.reference.SQLState;
import java.sql.SQLException;
+import java.util.Map;
+import org.apache.derby.shared.common.reference.SQLState;
/**
* A simple delegation wrapper handle for a physical connection.
@@ -444,7 +445,7 @@ public class LogicalConnection implement
}
}
- synchronized public java.util.Map getTypeMap() throws SQLException {
+ synchronized public Map<String, Class<?>> getTypeMap() throws SQLException {
try {
checkForNullPhysicalConnection();
return physicalConnection_.getTypeMap();
@@ -454,7 +455,7 @@ public class LogicalConnection implement
}
}
- synchronized public void setTypeMap(java.util.Map map) throws SQLException {
+ synchronized public void setTypeMap(Map map) throws SQLException {
try {
checkForNullPhysicalConnection();
physicalConnection_.setTypeMap(map);
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalConnection40.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalConnection40.java?rev=1362419&r1=1362418&r2=1362419&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalConnection40.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalConnection40.java Tue Jul 17 09:08:07 2012
@@ -23,19 +23,17 @@ package org.apache.derby.client.am;
import java.sql.Array;
import java.sql.Blob;
-import java.sql.SQLClientInfoException;
import java.sql.Clob;
import java.sql.NClob;
-import java.sql.SQLXML;
+import java.sql.SQLClientInfoException;
import java.sql.SQLException;
+import java.sql.SQLXML;
import java.sql.Struct;
import java.util.Properties;
import java.util.concurrent.Executor;
-
import org.apache.derby.client.ClientPooledConnection;
import org.apache.derby.client.net.NetConnection40;
import org.apache.derby.shared.common.reference.SQLState;
-import java.util.Map;
/**
* A simple delegation wrapper handle for a physical connection.
@@ -181,23 +179,6 @@ public class LogicalConnection40
}
/**
- * Returns the type map for this connection.
- *
- * @return type map for this connection
- * @exception SQLException if a database access error occurs
- */
- public Map<String, Class<?>> getTypeMap() throws SQLException {
- try
- {
- checkForNullPhysicalConnection();
- return ((java.sql.Connection) physicalConnection_).getTypeMap();
- } catch (SQLException sqle) {
- notifyException(sqle);
- throw sqle;
- }
- }
-
- /**
* Checks if the connection has not been closed and is still valid.
* The validity is checked by running a simple query against the
* database.
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement.java?rev=1362419&r1=1362418&r2=1362419&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement.java Tue Jul 17 09:08:07 2012
@@ -70,7 +70,7 @@ public class PreparedStatement extends S
public ColumnMetaData parameterMetaData_; // type information for input sqlda
- private ArrayList parameterTypeList;
+ private ArrayList<int[]> parameterTypeList;
// The problem with storing the scrollable ResultSet associated with cursorName in scrollableRS_ is
@@ -1614,7 +1614,7 @@ public class PreparedStatement extends S
checkThatAllParametersAreSet();
if (parameterTypeList == null) {
- parameterTypeList = new ArrayList();
+ parameterTypeList = new ArrayList<int[]>();
}
// ASSERT: since OUT/INOUT parameters are not allowed, there should
@@ -2267,7 +2267,7 @@ public class PreparedStatement extends S
for (int i = 0; i < batchSize; i++) {
if (parameterMetaData_ != null) {
- parameterMetaData_.clientParamtertype_ = (int[]) parameterTypeList.get(i);
+ parameterMetaData_.clientParamtertype_ = parameterTypeList.get(i);
parameters_ = (Object[]) batch_.get(i);
}
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/ResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/ResultSet.java?rev=1362419&r1=1362418&r2=1362419&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/ResultSet.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/ResultSet.java Tue Jul 17 09:08:07 2012
@@ -4875,11 +4875,11 @@ public abstract class ResultSet implemen
// currentRowInRowset_ should never be bigger than the max value of an int,
// because we have a driver imposed limit of fetch size 1000.
cursor_.columnDataPosition_ =
- (int[]) cursor_.columnDataPositionCache_.get((int) currentRowInRowset_);
+ cursor_.columnDataPositionCache_.get((int) currentRowInRowset_);
cursor_.columnDataComputedLength_ =
- (int[]) cursor_.columnDataLengthCache_.get((int) currentRowInRowset_);
+ cursor_.columnDataLengthCache_.get((int) currentRowInRowset_);
cursor_.isNull_ =
- (boolean[]) cursor_.columnDataIsNullCache_.get((int) currentRowInRowset_);
+ cursor_.columnDataIsNullCache_.get((int) currentRowInRowset_);
cursor_.isUpdateDeleteHole_ = ((Boolean) cursor_.isUpdateDeleteHoleCache_.get((int) currentRowInRowset_)).booleanValue();
}
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/SectionManager.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/SectionManager.java?rev=1362419&r1=1362418&r2=1362419&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/SectionManager.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/SectionManager.java Tue Jul 17 09:08:07 2012
@@ -22,8 +22,8 @@
package org.apache.derby.client.am;
import java.lang.ref.WeakReference;
-
-
+import java.util.Hashtable;
+import java.util.Stack;
import org.apache.derby.shared.common.reference.SQLState;
@@ -44,8 +44,8 @@ public class SectionManager {
// For performance, the section objects themselves are pooled,
// rather than just keeping track of free section numbers;
// this way, we don't have to new-up a section if one is available in the pool.
- java.util.Stack freeSectionsNonHold_ = null;
- java.util.Stack freeSectionsHold_ = null;
+ private final Stack<Section> freeSectionsNonHold_;
+ private final Stack<Section> freeSectionsHold_;
int nextAvailableSectionNumber_ = 1;
@@ -74,11 +74,15 @@ public class SectionManager {
// When requested (rs.getCursorName()), if the cursor name is still null,
// then is given the canned cursor name as defined by our jdbc package set and added to the cursor map.
// Still need to consider how positioned updates should interact with multiple result sets from a stored.
- private java.util.Hashtable positionedUpdateCursorNameToQuerySection_ = new java.util.Hashtable();
+ private final Hashtable<String, Section>
+ positionedUpdateCursorNameToQuerySection_ =
+ new Hashtable<String, Section>();
// Cursor name to ResultSet mapping is needed for positioned updates to check whether
// a ResultSet is scrollable. If so, exception is thrown.
- private java.util.Hashtable positionedUpdateCursorNameToResultSet_ = new java.util.Hashtable();
+ private final Hashtable<String, WeakReference<ResultSet>>
+ positionedUpdateCursorNameToResultSet_ =
+ new Hashtable<String, WeakReference<ResultSet>>();
String databaseName;
@@ -88,8 +92,8 @@ public class SectionManager {
collection_ = collection;
agent_ = agent;
this.databaseName = databaseName;
- freeSectionsNonHold_ = new java.util.Stack();
- freeSectionsHold_ = new java.util.Stack();
+ freeSectionsNonHold_ = new Stack<Section>();
+ freeSectionsHold_ = new Stack<Section>();
}
/**
@@ -186,11 +190,12 @@ public class SectionManager {
void mapCursorNameToResultSet(String cursorName, ResultSet resultSet) {
// DERBY-3316. Needs WeakReference so that ResultSet can be garbage collected
- positionedUpdateCursorNameToResultSet_.put(cursorName, new WeakReference(resultSet));
+ positionedUpdateCursorNameToResultSet_.put(
+ cursorName, new WeakReference<ResultSet>(resultSet));
}
ResultSet getPositionedUpdateResultSet(String cursorName) throws SqlException {
- ResultSet rs = (ResultSet) ((WeakReference) (positionedUpdateCursorNameToResultSet_.get(cursorName))).get();
+ ResultSet rs = positionedUpdateCursorNameToResultSet_.get(cursorName).get();
if (rs == null) {
throw new SqlException(agent_.logWriter_,
new ClientMessageId(SQLState.LANG_RESULT_SET_NOT_OPEN), "update");
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/Statement.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/Statement.java?rev=1362419&r1=1362418&r2=1362419&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/Statement.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/Statement.java Tue Jul 17 09:08:07 2012
@@ -21,8 +21,8 @@
package org.apache.derby.client.am;
import java.sql.SQLException;
+import java.util.ArrayList;
import java.util.Arrays;
-
import org.apache.derby.shared.common.reference.SQLState;
import org.apache.derby.shared.common.sanity.SanityManager;
@@ -136,7 +136,7 @@ public class Statement implements java.s
ResultSet[] resultSetList_ = null; // array of ResultSet objects
protected final static String TIMEOUT_STATEMENT = "SET STATEMENT_TIMEOUT ";
- protected java.util.ArrayList timeoutArrayList = new java.util.ArrayList(1);
+ protected ArrayList<String> timeoutArrayList = new ArrayList<String>(1);
protected boolean doWriteTimeout = false;
int timeout_ = 0; // for query timeout in seconds
int maxRows_ = 0;
@@ -156,7 +156,7 @@ public class Statement implements java.s
// This collection is used for two different purposes:
// For statement batching it contains the batched SQL strings.
// For prepared statement batching it contains the batched input rows.
- final java.util.ArrayList batch_ = new java.util.ArrayList();
+ final ArrayList<Object> batch_ = new ArrayList<Object>();
// Scrollable cursor attributes
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/StatementCacheInteractor.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/StatementCacheInteractor.java?rev=1362419&r1=1362418&r2=1362419&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/StatementCacheInteractor.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/StatementCacheInteractor.java Tue Jul 17 09:08:07 2012
@@ -24,10 +24,7 @@ package org.apache.derby.client.am;
import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.SQLException;
-
import java.util.ArrayList;
-import java.util.Iterator;
-
import org.apache.derby.client.am.stmtcache.JDBCStatementCache;
import org.apache.derby.client.am.stmtcache.StatementKey;
import org.apache.derby.client.am.stmtcache.StatementKeyFactory;
@@ -62,7 +59,8 @@ public final class StatementCacheInterac
private final Connection physicalConnection;
/** List of open logical statements created by this cache interactor. */
//@GuardedBy("this")
- private final ArrayList openLogicalStatements = new ArrayList();
+ private final ArrayList<LogicalStatementEntity> openLogicalStatements =
+ new ArrayList<LogicalStatementEntity>();
/**
* Tells if this interactor is in the process of shutting down.
* <p>
@@ -217,10 +215,7 @@ public final class StatementCacheInterac
// statements as we work our way through the list.
this.connCloseInProgress = true;
// Iterate through the list and close the logical statements.
- Iterator logicalStatements = this.openLogicalStatements.iterator();
- while (logicalStatements.hasNext()) {
- LogicalStatementEntity logicalStatement =
- (LogicalStatementEntity)logicalStatements.next();
+ for (LogicalStatementEntity logicalStatement : openLogicalStatements) {
logicalStatement.close();
}
// Clear the list for good measure.
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/stmtcache/JDBCStatementCache.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/stmtcache/JDBCStatementCache.java?rev=1362419&r1=1362418&r2=1362419&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/stmtcache/JDBCStatementCache.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/stmtcache/JDBCStatementCache.java Tue Jul 17 09:08:07 2012
@@ -53,7 +53,7 @@ public final class JDBCStatementCache {
/** Structure holding the cached prepared statement objects. */
//@GuardedBy("this");
- private final LinkedHashMap statements;
+ private final LinkedHashMap<StatementKey, PreparedStatement> statements;
/**
* Creates a new, empty JDBC statement cache.
@@ -83,7 +83,7 @@ public final class JDBCStatementCache {
SanityManager.ASSERT(statementKey != null,
"statementKey is not supposed to be null");
}
- return (PreparedStatement)this.statements.remove(statementKey);
+ return statements.remove(statementKey);
}
/**
@@ -117,7 +117,8 @@ public final class JDBCStatementCache {
* removed after the new entry has been inserted.
*/
//@NotThreadSafe
- private static class BoundedLinkedHashMap extends LinkedHashMap {
+ private static class BoundedLinkedHashMap
+ extends LinkedHashMap<StatementKey, PreparedStatement> {
/** Maximum number of entries. */
private final int maxSize;
@@ -146,11 +147,12 @@ public final class JDBCStatementCache {
* @return <code>true</code> if the element is to be removed,
* <code>false</code> if not.
*/
- protected boolean removeEldestEntry(Map.Entry eldest) {
+ protected boolean removeEldestEntry(
+ Map.Entry<StatementKey, PreparedStatement> eldest) {
final boolean remove = size() > maxSize;
if (remove && eldest != null) {
try {
- ((PreparedStatement)eldest.getValue()).close();
+ eldest.getValue().close();
} catch (SQLException ex) {
// Ignore this exception in insane mode, throw an assertion
// error if a sane build is run.
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/net/CodePointNameTable.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/net/CodePointNameTable.java?rev=1362419&r1=1362418&r2=1362419&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/net/CodePointNameTable.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/net/CodePointNameTable.java Tue Jul 17 09:08:07 2012
@@ -27,7 +27,7 @@ package org.apache.derby.client.net;
// This data type may be modified for performance to adapt to any sort of lookup implementation,
// such as binary search on an underlying sorted array.
-class CodePointNameTable extends java.util.Hashtable {
+class CodePointNameTable extends java.util.Hashtable<Integer, String> {
CodePointNameTable() {
put(new Integer(CodePoint.ACCSECRD), "ACCSECRD");
put(new Integer(CodePoint.TYPDEFNAM), "TYPDEFNAM");
@@ -91,6 +91,6 @@ class CodePointNameTable extends java.ut
}
String lookup(int codePoint) {
- return (String) get(new Integer(codePoint));
+ return get(codePoint);
}
}
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConnection40.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConnection40.java?rev=1362419&r1=1362418&r2=1362419&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConnection40.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConnection40.java Tue Jul 17 09:08:07 2012
@@ -22,8 +22,6 @@
package org.apache.derby.client.net;
import java.sql.Array;
-import org.apache.derby.client.am.SQLExceptionFactory;
-import org.apache.derby.client.am.SqlException;
import java.sql.NClob;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
@@ -32,12 +30,13 @@ import java.sql.SQLException;
import java.sql.SQLPermission;
import java.sql.SQLXML;
import java.sql.Struct;
-import java.util.Map;
import java.util.Properties;
import java.util.concurrent.Executor;
import org.apache.derby.client.ClientPooledConnection;
import org.apache.derby.client.am.ClientMessageId;
import org.apache.derby.client.am.FailedProperties40;
+import org.apache.derby.client.am.SQLExceptionFactory;
+import org.apache.derby.client.am.SqlException;
import org.apache.derby.shared.common.reference.SQLState;
public class NetConnection40 extends org.apache.derby.client.net.NetConnection {
@@ -326,21 +325,6 @@ public class NetConnection40 extends or
catch (SqlException se) { throw se.getSQLException(); }
}
-
- /**
- * Returns the type map for this connection.
- *
- * @return type map for this connection
- * @exception SQLException if a database access error occurs
- */
- @SuppressWarnings("unchecked")
- public final Map<String, Class<?>> getTypeMap() throws SQLException {
- // Return the map from the super class. The method is overridden
- // just to get the generic signature and prevent an unchecked warning
- // at compile time.
- return super.getTypeMap();
- }
-
/**
* Returns false unless <code>interfaces</code> is implemented
*
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/net/NetCursor.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/net/NetCursor.java?rev=1362419&r1=1362418&r2=1362419&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/net/NetCursor.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/net/NetCursor.java Tue Jul 17 09:08:07 2012
@@ -21,17 +21,19 @@
package org.apache.derby.client.net;
+import java.util.ArrayList;
+import java.util.HashMap;
import org.apache.derby.client.am.Agent;
import org.apache.derby.client.am.Blob;
+import org.apache.derby.client.am.ClientMessageId;
import org.apache.derby.client.am.Clob;
import org.apache.derby.client.am.DisconnectException;
import org.apache.derby.client.am.Lob;
import org.apache.derby.client.am.SignedBinary;
+import org.apache.derby.client.am.SqlCode;
import org.apache.derby.client.am.SqlException;
-import org.apache.derby.client.am.ClientMessageId;
import org.apache.derby.client.am.SqlWarning;
import org.apache.derby.client.am.Types;
-import org.apache.derby.client.am.SqlCode;
import org.apache.derby.shared.common.reference.SQLState;
import org.apache.derby.shared.common.sanity.SanityManager;
@@ -55,8 +57,13 @@ public class NetCursor extends org.apach
boolean[] isGraphic_;
// key = column position, value = index into extdtaData_
- java.util.HashMap extdtaPositions_;
- java.util.ArrayList extdtaData_; // queue to hold EXTDTA data that hasn't been correlated to its column #
+ HashMap<Integer, Integer> extdtaPositions_;
+
+ /**
+ * Queue to hold EXTDTA data that hasn't been correlated to its
+ * column number.
+ */
+ ArrayList<byte[]> extdtaData_;
boolean rtnextrow_ = true;
@@ -74,8 +81,8 @@ public class NetCursor extends org.apach
netAgent_ = netAgent;
numMddOverrides_ = 0;
maximumRowSize_ = 0;
- extdtaPositions_ = new java.util.HashMap();
- extdtaData_ = new java.util.ArrayList();
+ extdtaPositions_ = new HashMap<Integer, Integer>();
+ extdtaData_ = new ArrayList<byte[]>();
}
NetCursor(NetAgent netAgent,
@@ -882,7 +889,7 @@ public class NetCursor extends org.apach
if (extdtaPositions_.containsKey(key)) {
// found, get the data
int extdtaQueuePosition = ((Integer) extdtaPositions_.get(key)).intValue();
- data = (byte[]) (extdtaData_.get(extdtaQueuePosition));
+ data = extdtaData_.get(extdtaQueuePosition);
}
return data;
@@ -1138,7 +1145,7 @@ public class NetCursor extends org.apach
columnDataPosition = new int[columns_];
columnDataPositionCache_.add(columnDataPosition);
} else {
- columnDataPosition = (int[]) columnDataPositionCache_.get(row);
+ columnDataPosition = columnDataPositionCache_.get(row);
}
return columnDataPosition;
}
@@ -1149,7 +1156,7 @@ public class NetCursor extends org.apach
columnDataComputedLength = new int[columns_];
columnDataLengthCache_.add(columnDataComputedLength);
} else {
- columnDataComputedLength = (int[]) columnDataLengthCache_.get(row);
+ columnDataComputedLength = columnDataLengthCache_.get(row);
}
return columnDataComputedLength;
}
@@ -1160,7 +1167,7 @@ public class NetCursor extends org.apach
columnDataIsNull = new boolean[columns_];
columnDataIsNullCache_.add(columnDataIsNull);
} else {
- columnDataIsNull = (boolean[]) columnDataIsNullCache_.get(row);
+ columnDataIsNull = columnDataIsNullCache_.get(row);
}
return columnDataIsNull;
}
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/net/NetStatementReply.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/net/NetStatementReply.java?rev=1362419&r1=1362418&r2=1362419&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/net/NetStatementReply.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/net/NetStatementReply.java Tue Jul 17 09:08:07 2012
@@ -22,24 +22,23 @@
package org.apache.derby.client.net;
import java.sql.ResultSet;
-
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.derby.client.am.ClientMessageId;
import org.apache.derby.client.am.ColumnMetaData;
import org.apache.derby.client.am.DisconnectException;
import org.apache.derby.client.am.PreparedStatementCallbackInterface;
import org.apache.derby.client.am.ResultSetCallbackInterface;
import org.apache.derby.client.am.Section;
-import org.apache.derby.client.am.SqlState;
import org.apache.derby.client.am.SqlException;
import org.apache.derby.client.am.Statement;
import org.apache.derby.client.am.StatementCallbackInterface;
import org.apache.derby.client.am.Types;
import org.apache.derby.client.am.Utils;
import org.apache.derby.jdbc.ClientDriver;
-import org.apache.derby.client.am.ClientJDBCObjectFactory;
import org.apache.derby.shared.common.i18n.MessageUtil;
-import org.apache.derby.client.am.ClientMessageId;
-import org.apache.derby.shared.common.reference.SQLState;
import org.apache.derby.shared.common.reference.MessageId;
+import org.apache.derby.shared.common.reference.SQLState;
public class NetStatementReply extends NetPackageReply implements StatementReplyInterface {
NetStatementReply(NetAgent netAgent, int bufferSize) {
@@ -371,7 +370,7 @@ public class NetStatementReply extends N
// server.
// the result set summary component consists of a result set reply message.
- java.util.ArrayList sectionAL = parseRSLSETRM();
+ List<Section> sectionAL = parseRSLSETRM();
// following the RSLSETRM is an SQLCARD or an SQLDTARD. check for a
// TYPDEFNAM or TYPDEFOVR before looking for these objects.
@@ -405,7 +404,8 @@ public class NetStatementReply extends N
NetResultSet[] resultSets = new NetResultSet[numberOfResultSets];
for (int i = 0; i < numberOfResultSets; i++) {
// parse the result set component of the stored procedure reply.
- NetResultSet netResultSet = parseResultSetCursor(statementI, (Section) sectionAL.get(i));
+ NetResultSet netResultSet =
+ parseResultSetCursor(statementI, sectionAL.get(i));
resultSets[i] = netResultSet;
}
@@ -1142,11 +1142,11 @@ public class NetStatementReply extends N
// SVRCOD - required (0 INFO)
// PKGSNLST - required
// SRVDGN - optional
- protected java.util.ArrayList parseRSLSETRM() throws DisconnectException {
+ private List<Section> parseRSLSETRM() throws DisconnectException {
boolean svrcodReceived = false;
int svrcod = CodePoint.SVRCOD_INFO;
boolean pkgsnlstReceived = false;
- java.util.ArrayList pkgsnlst = null;
+ List<Section> pkgsnlst = null;
parseLengthAndMatchCodePoint(CodePoint.RSLSETRM);
pushLengthOnCollectionStack();
@@ -1545,7 +1545,7 @@ public class NetStatementReply extends N
//
// Only called for generated secctions from a callable statement.
//
- protected Object parsePKGNAMCSN(boolean skip) throws DisconnectException {
+ protected Section parsePKGNAMCSN(boolean skip) throws DisconnectException {
parseLengthAndMatchCodePoint(CodePoint.PKGNAMCSN);
if (skip) {
skipBytes();
@@ -1725,15 +1725,13 @@ public class NetStatementReply extends N
// RDB Package Namce, Consistency Token, and Section Number List
// specifies a list of fully qualified names of specific sections
// within one or more packages.
- protected java.util.ArrayList parsePKGSNLST() throws DisconnectException {
- Object pkgnamcsn = null;
- java.util.ArrayList pkgsnlst = new java.util.ArrayList(); // what default size should we use
+ private List<Section> parsePKGSNLST() throws DisconnectException {
+ ArrayList<Section> pkgsnlst = new ArrayList<Section>();
parseLengthAndMatchCodePoint(CodePoint.PKGSNLST);
pushLengthOnCollectionStack();
while (peekCodePoint() != Reply.END_OF_COLLECTION) {
- pkgnamcsn = parsePKGNAMCSN(false);
- pkgsnlst.add(pkgnamcsn);
+ pkgsnlst.add(parsePKGNAMCSN(false));
}
popCollectionStack();
return pkgsnlst;
@@ -1745,9 +1743,10 @@ public class NetStatementReply extends N
return parseSQLDARDarray(columnMetaData, skipBytes);
}
- protected int parseSQLRSLRD(java.util.ArrayList sectionAL) throws DisconnectException {
+ private int parseSQLRSLRD(List<Section> sections)
+ throws DisconnectException {
parseLengthAndMatchCodePoint(CodePoint.SQLRSLRD);
- return parseSQLRSLRDarray(sectionAL);
+ return parseSQLRSLRDarray(sections);
}
protected ColumnMetaData parseSQLCINRD() throws DisconnectException {
@@ -1845,10 +1844,11 @@ public class NetStatementReply extends N
// SQL Result Set Reply Data (SQLRSLRD) is a byte string that specifies
// information about result sets returned as reply data in the response to
// an EXCSQLSTT command that invokes a stored procedure
- int parseSQLRSLRDarray(java.util.ArrayList sectionAL) throws DisconnectException {
+ private int parseSQLRSLRDarray(List<Section> sections)
+ throws DisconnectException {
int numOfResultSets = parseSQLNUMROW();
for (int i = 0; i < numOfResultSets; i++) {
- parseSQLRSROW((Section) sectionAL.get(i));
+ parseSQLRSROW(sections.get(i));
}
return numOfResultSets;
}
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/net/NetStatementRequest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/net/NetStatementRequest.java?rev=1362419&r1=1362418&r2=1362419&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/net/NetStatementRequest.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/net/NetStatementRequest.java Tue Jul 17 09:08:07 2012
@@ -23,25 +23,28 @@ package org.apache.derby.client.net;
import java.sql.Date;
import java.sql.Time;
import java.sql.Timestamp;
-import org.apache.derby.iapi.reference.DRDAConstants;
-import org.apache.derby.client.am.Lob;
+import java.util.ArrayList;
+import java.util.HashMap;
import org.apache.derby.client.am.Blob;
+import org.apache.derby.client.am.ClientMessageId;
import org.apache.derby.client.am.Clob;
import org.apache.derby.client.am.ColumnMetaData;
import org.apache.derby.client.am.DateTime;
+import org.apache.derby.client.am.DateTimeValue;
+import org.apache.derby.client.am.Lob;
import org.apache.derby.client.am.ResultSet;
import org.apache.derby.client.am.Section;
import org.apache.derby.client.am.SqlException;
import org.apache.derby.client.am.Types;
-import org.apache.derby.client.am.ClientMessageId;
-import org.apache.derby.client.am.DateTimeValue;
import org.apache.derby.client.am.Utils;
+import org.apache.derby.iapi.reference.DRDAConstants;
import org.apache.derby.shared.common.reference.SQLState;
// For performance, should we worry about the ordering of our DDM command parameters
public class NetStatementRequest extends NetPackageRequest implements StatementRequestInterface {
- java.util.ArrayList extdtaPositions_ = null; // Integers: build EXTDTA for column i
+ // Integers: build EXTDTA for column i
+ private ArrayList<Integer> extdtaPositions_ = null;
// promototed parameters hold parameters that are promotoed to a different
// data type because they are too large to represent in PROTOCOL otherwise.
@@ -49,7 +52,8 @@ public class NetStatementRequest extends
// The key for this structure is the parameter index. Note that having this
// collection does not eliminate the need for extdtaPositions_ because that
// is still needed for non-promototed LOBs
- java.util.HashMap promototedParameters_ = new java.util.HashMap();
+ private final HashMap<Integer, Object> promototedParameters_ =
+ new HashMap<Integer, Object>();
NetStatementRequest(NetAgent netAgent, int bufferSize) {
super(netAgent, bufferSize);
@@ -927,7 +931,7 @@ public class NetStatementRequest extends
boolean chainFlag, chainedWithSameCorrelator;
for (int i = 0; i < extdtaPositions_.size(); i++) {
- int index = ((Integer) extdtaPositions_.get(i)).intValue();
+ int index = extdtaPositions_.get(i);
// is this the last EXTDTA to be built?
if (i != extdtaPositions_.size() - 1) { // no
@@ -1117,7 +1121,7 @@ public class NetStatementRequest extends
if (promototedParameters_.isEmpty()) {
return null;
}
- return promototedParameters_.get(new Integer(index));
+ return promototedParameters_.get(index);
}
private int calculateColumnsInSQLDTAGRPtriplet(int numVars) {
@@ -1192,7 +1196,7 @@ public class NetStatementRequest extends
// inputRow[i] = c;
// Place the new Lob in the promototedParameter_ collection for
// NetStatementRequest use
- promototedParameters_.put(new Integer(i), c);
+ promototedParameters_.put(i, c);
lidAndLengths[i][0] = DRDAConstants.DRDA_TYPE_NLOBCMIXED;
@@ -1340,7 +1344,7 @@ public class NetStatementRequest extends
// inputRow[i] = c;
// Place the new Lob in the promototedParameter_ collection for
// NetStatementRequest use
- promototedParameters_.put(new Integer(i), c);
+ promototedParameters_.put(i, c);
lidAndLengths[i][0] = DRDAConstants.DRDA_TYPE_NLOBCMIXED;
lidAndLengths[i][1] = buildPlaceholderLength(c.length());
@@ -1367,7 +1371,7 @@ public class NetStatementRequest extends
// inputRow[i] = b;
// Place the new Lob in the promototedParameter_ collection for
// NetStatementRequest use
- promototedParameters_.put(new Integer(i), b);
+ promototedParameters_.put(i, b);
lidAndLengths[i][0] = DRDAConstants.DRDA_TYPE_NLOBBYTES;
lidAndLengths[i][1] = buildPlaceholderLength(ba.length);
@@ -1388,7 +1392,7 @@ public class NetStatementRequest extends
// inputRow[i] = b;
// Place the new Lob in the promototedParameter_ collection for
// NetStatementRequest use
- promototedParameters_.put(new Integer(i), b);
+ promototedParameters_.put(i, b);
lidAndLengths[i][0] = DRDAConstants.DRDA_TYPE_NLOBBYTES;
lidAndLengths[i][1] = buildPlaceholderLength(ba.length);
@@ -1775,9 +1779,9 @@ public class NetStatementRequest extends
if (dataLength != 0) {
if (extdtaPositions_ == null) {
- extdtaPositions_ = new java.util.ArrayList();
+ extdtaPositions_ = new ArrayList<Integer>();
}
- extdtaPositions_.add(new Integer(i));
+ extdtaPositions_.add(i);
}
}
@@ -1785,10 +1789,10 @@ public class NetStatementRequest extends
short v = 1;
writeShort( v <<= 15 );
if (extdtaPositions_ == null) {
- extdtaPositions_ = new java.util.ArrayList();
+ extdtaPositions_ = new ArrayList<Integer>();
}
- extdtaPositions_.add(new Integer(i));
+ extdtaPositions_.add(i);
}
private boolean checkSendQryrowset(int fetchSize,
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/net/NetXAConnectionReply.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/net/NetXAConnectionReply.java?rev=1362419&r1=1362418&r2=1362419&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/net/NetXAConnectionReply.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/net/NetXAConnectionReply.java Tue Jul 17 09:08:07 2012
@@ -149,7 +149,6 @@ public class NetXAConnectionReply extend
int svrcod = CodePoint.SVRCOD_INFO;
int xaretval = 0;
int synctype = 0;
- java.util.Hashtable indoubtTransactions = null;
NetConnection conn = netAgent_.netConnection_;
parseLengthAndMatchCodePoint(CodePoint.SYNCCRD);
@@ -183,8 +182,7 @@ public class NetXAConnectionReply extend
if (peekCP == CodePoint.PRPHRCLST) {
foundInPass = true;
- indoubtTransactions = parseIndoubtList();
- conn.setIndoubtTransactions(indoubtTransactions);
+ conn.setIndoubtTransactions(parseIndoubtList());
peekCP = peekCodePoint();
}
@@ -306,7 +304,8 @@ public class NetXAConnectionReply extend
peekCP = peekCodePoint();
}
- java.util.Hashtable indoubtTransactions = new java.util.Hashtable();
+ java.util.Hashtable<Xid, NetIndoubtTransaction> indoubtTransactions =
+ new java.util.Hashtable<Xid, NetIndoubtTransaction>();
while (peekCP == CodePoint.XID) {
Xid xid = parseXID();
indoubtTransactions.put(xid, new NetIndoubtTransaction(xid, null, null, null, sIpAddr, port));
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/net/NetXAResource.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/net/NetXAResource.java?rev=1362419&r1=1362418&r2=1362419&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/net/NetXAResource.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/net/NetXAResource.java Tue Jul 17 09:08:07 2012
@@ -102,7 +102,8 @@ public class NetXAResource implements XA
int port_; // port needed to make secondary connection for recover in DS mode.
String ipaddr_; // ip address needed to make secondary connection for recover in DS mode.
- private List specialRegisters_ = Collections.synchronizedList(new LinkedList());
+ private final List<String> specialRegisters_ =
+ Collections.synchronizedList(new LinkedList<String>());
/** The value of the transaction timeout in seconds. */
private int timeoutSeconds = 0;
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/net/OpenSocketAction.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/net/OpenSocketAction.java?rev=1362419&r1=1362418&r2=1362419&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/net/OpenSocketAction.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/net/OpenSocketAction.java Tue Jul 17 09:08:07 2012
@@ -21,12 +21,12 @@
package org.apache.derby.client.net;
+import java.net.Socket;
+import java.security.PrivilegedExceptionAction;
import javax.net.SocketFactory;
import javax.net.ssl.SSLSocketFactory;
-import javax.net.ssl.SSLServerSocketFactory;
-import javax.net.ssl.SSLSocket;
-public class OpenSocketAction implements java.security.PrivilegedExceptionAction {
+public class OpenSocketAction implements PrivilegedExceptionAction<Socket> {
private String server_;
private int port_;
private int clientSSLMode_;
@@ -37,7 +37,8 @@ public class OpenSocketAction implements
clientSSLMode_ = clientSSLMode;
}
- public Object run()
+ @Override
+ public Socket run()
throws java.net.UnknownHostException,
java.io.IOException,
java.security.NoSuchAlgorithmException,
Modified: db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientBaseDataSource.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientBaseDataSource.java?rev=1362419&r1=1362418&r2=1362419&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientBaseDataSource.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientBaseDataSource.java Tue Jul 17 09:08:07 2012
@@ -21,31 +21,30 @@
package org.apache.derby.jdbc;
-import java.io.Serializable;
-import java.io.PrintWriter;
import java.io.File;
-import java.security.AccessController;
-import java.util.Properties;
-import java.util.StringTokenizer;
-import java.util.NoSuchElementException;
+import java.io.PrintWriter;
+import java.io.Serializable;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
-
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import java.sql.SQLException;
-import javax.naming.Referenceable;
-import javax.naming.Reference;
+import java.util.NoSuchElementException;
+import java.util.Properties;
+import java.util.StringTokenizer;
import javax.naming.NamingException;
+import javax.naming.Reference;
+import javax.naming.Referenceable;
import javax.naming.StringRefAddr;
-
+import org.apache.derby.client.ClientDataSourceFactory;
+import org.apache.derby.client.am.ClientMessageId;
import org.apache.derby.client.am.Configuration;
+import org.apache.derby.client.am.Connection;
import org.apache.derby.client.am.LogWriter;
import org.apache.derby.client.am.SqlException;
-import org.apache.derby.client.am.Connection;
-import org.apache.derby.client.am.ClientMessageId;
import org.apache.derby.client.net.NetConfiguration;
import org.apache.derby.client.net.NetLogWriter;
-import org.apache.derby.client.ClientDataSourceFactory;
import org.apache.derby.shared.common.error.ExceptionUtil;
import org.apache.derby.shared.common.reference.Attribute;
import org.apache.derby.shared.common.reference.SQLState;
@@ -445,9 +444,8 @@ public abstract class ClientBaseDataSour
//readSystemProperty, have an anonymous class implement PrivilegeAction.
//This class will read the system property in it's run method and
//return the value to the caller.
- return (String )AccessController.doPrivileged
- (new java.security.PrivilegedAction(){
- public Object run(){
+ return AccessController.doPrivileged(new PrivilegedAction<String>() {
+ public String run() {
try {
return System.getProperty(key);
} catch (SecurityException se) {