MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:mmatthews Date:April 4 2006 7:47pm
Subject:Connector/J commit: r5134 - branches/branch_5_0/connector-j/src/com/mysql/jdbc
View as plain text  
Modified:
   branches/branch_5_0/connector-j/src/com/mysql/jdbc/CallableStatement.java
   branches/branch_5_0/connector-j/src/com/mysql/jdbc/Connection.java
   branches/branch_5_0/connector-j/src/com/mysql/jdbc/PreparedStatement.java
   branches/branch_5_0/connector-j/src/com/mysql/jdbc/ResultSet.java
   branches/branch_5_0/connector-j/src/com/mysql/jdbc/Statement.java
   branches/branch_5_0/connector-j/src/com/mysql/jdbc/UpdatableResultSet.java
Log:
More synchronization fixes.

Modified: branches/branch_5_0/connector-j/src/com/mysql/jdbc/CallableStatement.java
===================================================================
--- branches/branch_5_0/connector-j/src/com/mysql/jdbc/CallableStatement.java	2006-04-04 15:53:24 UTC (rev 5133)
+++ branches/branch_5_0/connector-j/src/com/mysql/jdbc/CallableStatement.java	2006-04-04 19:47:49 UTC (rev 5134)
@@ -629,7 +629,7 @@
 	 * 
 	 * @see java.sql.PreparedStatement#executeQuery()
 	 */
-	public synchronized java.sql.ResultSet executeQuery() throws SQLException {
+	public java.sql.ResultSet executeQuery() throws SQLException {
 		checkClosed();
 
 		checkStreamability();
@@ -653,7 +653,7 @@
 	 * 
 	 * @see java.sql.PreparedStatement#executeUpdate()
 	 */
-	public synchronized int executeUpdate() throws SQLException {
+	public int executeUpdate() throws SQLException {
 		int returnVal = -1;
 
 		checkClosed();

Modified: branches/branch_5_0/connector-j/src/com/mysql/jdbc/Connection.java
===================================================================
--- branches/branch_5_0/connector-j/src/com/mysql/jdbc/Connection.java	2006-04-04 15:53:24 UTC (rev 5133)
+++ branches/branch_5_0/connector-j/src/com/mysql/jdbc/Connection.java	2006-04-04 19:47:49 UTC (rev 5134)
@@ -1411,12 +1411,7 @@
 			String databaseToConnectTo, String url)
 			throws SQLException {
 		this.charsetToNumBytesMap = new HashMap();
-		
-		if (getCacheCallableStatements()) {
-			this.parsedCallableStatementCache = new LRUCache(
-					getCallableStatementCacheSize());
-		}
-		
+
 		this.connectionCreationTimeMillis = System.currentTimeMillis();
 		this.pointOfOrigin = new Throwable();
 		
@@ -3725,6 +3720,11 @@
 							+ "properties at the same time",
 					SQLError.SQL_STATE_INVALID_CONNECTION_ATTRIBUTE);
 		}
+		
+		if (getCacheCallableStatements()) {
+			this.parsedCallableStatementCache = new LRUCache(
+					getCallableStatementCacheSize());
+		}
 	}
 
 	private void createPreparedStatementCaches() {

Modified: branches/branch_5_0/connector-j/src/com/mysql/jdbc/PreparedStatement.java
===================================================================
--- branches/branch_5_0/connector-j/src/com/mysql/jdbc/PreparedStatement.java	2006-04-04 15:53:24 UTC (rev 5133)
+++ branches/branch_5_0/connector-j/src/com/mysql/jdbc/PreparedStatement.java	2006-04-04 19:47:49 UTC (rev 5134)
@@ -824,6 +824,8 @@
 	 *             DOCUMENT ME!
 	 */
 	public int[] executeBatch() throws SQLException {
+		checkClosed();
+		
 		if (this.connection.isReadOnly()) {
 			throw new SQLException(Messages.getString("PreparedStatement.25") //$NON-NLS-1$
 					+ Messages.getString("PreparedStatement.26"), //$NON-NLS-1$
@@ -1158,7 +1160,7 @@
 	 * @exception SQLException
 	 *                if a database access error occurs
 	 */
-	public synchronized java.sql.ResultSet executeQuery() throws SQLException {
+	public java.sql.ResultSet executeQuery() throws SQLException {
 		checkClosed();
 
 		checkForDml(this.originalSql, this.firstCharOfStmt);
@@ -1273,7 +1275,7 @@
 	 * @exception SQLException
 	 *                if a database access error occurs
 	 */
-	public synchronized int executeUpdate() throws SQLException {
+	public int executeUpdate() throws SQLException {
 		return executeUpdate(true, false);
 	}
 
@@ -1282,7 +1284,7 @@
 	 * batched updates, which will end up clobbering the warnings and generated
 	 * keys we need to gather for the batch.
 	 */
-	protected synchronized int executeUpdate(
+	protected int executeUpdate(
 			boolean clearBatchedGeneratedKeysAndWarnings, boolean isBatch) throws SQLException {
 		if (clearBatchedGeneratedKeysAndWarnings) {
 			clearWarnings();
@@ -1312,18 +1314,19 @@
 	 * @throws SQLException
 	 *             if a database error occurs
 	 */
-	protected synchronized int executeUpdate(byte[][] batchedParameterStrings,
+	protected int executeUpdate(byte[][] batchedParameterStrings,
 			InputStream[] batchedParameterStreams, boolean[] batchedIsStream,
 			int[] batchedStreamLengths, boolean[] batchedIsNull, boolean isReallyBatch)
 			throws SQLException {
+
+		checkClosed();
+		
 		if (this.connection.isReadOnly()) {
 			throw SQLError.createSQLException(Messages.getString("PreparedStatement.34") //$NON-NLS-1$
 					+ Messages.getString("PreparedStatement.35"), //$NON-NLS-1$
 					SQLError.SQL_STATE_ILLEGAL_ARGUMENT);
 		}
 
-		checkClosed();
-
 		if ((this.firstCharOfStmt == 'S')
 				&& StringUtils.startsWithIgnoreCaseAndWs(this.originalSql,
 						"SELECT")) { //$NON-NLS-1$
@@ -1401,7 +1404,7 @@
 		return truncatedUpdateCount;
 	}
 
-	private synchronized String extractValuesClause() throws SQLException {
+	private String extractValuesClause() throws SQLException {
 		if (this.batchedValuesClause == null) {
 			String quoteCharStr = this.connection.getMetaData()
 					.getIdentifierQuoteString();
@@ -1751,7 +1754,7 @@
 	 * @exception SQLException
 	 *                if a database-access error occurs.
 	 */
-	public synchronized java.sql.ResultSetMetaData getMetaData()
+	public java.sql.ResultSetMetaData getMetaData()
 			throws SQLException {
 
 		if (!StringUtils.startsWithIgnoreCaseAndNonAlphaNumeric(
@@ -1820,7 +1823,7 @@
 	/**
 	 * @see PreparedStatement#getParameterMetaData()
 	 */
-	public synchronized ParameterMetaData getParameterMetaData() 
+	public ParameterMetaData getParameterMetaData() 
 		throws SQLException {
 		if (this.parameterMetaData == null) {
 			this.parameterMetaData = new MysqlParameterMetadata(
@@ -1996,7 +1999,7 @@
 	 * @exception SQLException
 	 *                if a database access error occurs
 	 */
-	public synchronized void setAsciiStream(int parameterIndex, InputStream x,
+	public void setAsciiStream(int parameterIndex, InputStream x,
 			int length) throws SQLException {
 		if (x == null) {
 			setNull(parameterIndex, java.sql.Types.VARCHAR);
@@ -2543,6 +2546,8 @@
 
 	private final void setInternal(int paramIndex, String val)
 			throws SQLException {
+		checkClosed();
+		
 		byte[] parameterAsBytes = null;
 
 		if (this.charConverter != null) {
@@ -3174,6 +3179,8 @@
 		if (x == null) {
 			setNull(parameterIndex, Types.CHAR);
 		} else {
+			checkClosed();
+			
 			int stringLength = x.length();
 
 			if (this.connection.isNoBackslashEscapesSet()) {
@@ -3405,6 +3412,8 @@
 		if (x == null) {
 			setNull(parameterIndex, java.sql.Types.TIME);
 		} else {
+			checkClosed();
+			
 			Calendar sessionCalendar = getCalendarInstanceForSessionOrNew();
 			
 			synchronized (sessionCalendar) {
@@ -3469,12 +3478,14 @@
 	 * @throws SQLException
 	 *             if a database-access error occurs.
 	 */
-	private synchronized void setTimestampInternal(int parameterIndex,
+	private void setTimestampInternal(int parameterIndex,
 			Timestamp x, Calendar targetCalendar,
 			TimeZone tz, boolean rollForward) throws SQLException {
 		if (x == null) {
 			setNull(parameterIndex, java.sql.Types.TIMESTAMP);
 		} else {
+			checkClosed();
+			
 			String timestampString = null;
 			
 			Calendar sessionCalendar = this.connection.getUseJDBCCompliantTimezoneShift() ?

Modified: branches/branch_5_0/connector-j/src/com/mysql/jdbc/ResultSet.java
===================================================================
--- branches/branch_5_0/connector-j/src/com/mysql/jdbc/ResultSet.java	2006-04-04 15:53:24 UTC (rev 5133)
+++ branches/branch_5_0/connector-j/src/com/mysql/jdbc/ResultSet.java	2006-04-04 19:47:49 UTC (rev 5134)
@@ -799,9 +799,13 @@
 		}
 
 		if (this.thisRow[columnIndexMinusOne] == null) {
+			this.wasNullFlag = true;
+			
 			return null;
 		}
 
+		this.wasNullFlag = false;
+		
 		String stringVal = null;
 
 		if ((this.connection != null) && this.connection.getUseUnicode()) {
@@ -2319,10 +2323,10 @@
 	 *                if a database access error occurs
 	 */
 	public int getInt(int columnIndex) throws SQLException {
+		checkRowPos();
+		
 		if (!this.isBinaryEncoded) {
 			if (this.connection.getUseFastIntParsing()) {
-				checkRowPos();
-
 				checkColumnBounds(columnIndex);
 				
 				try {
@@ -2532,9 +2536,10 @@
 	 */
 	public long getLong(int columnIndex) throws SQLException {
 		if (!this.isBinaryEncoded) {
+			checkRowPos();
+			
 			if (this.connection.getUseFastIntParsing()) {
-				checkRowPos();
-
+			
 				checkColumnBounds(columnIndex);
 				
 				try {
@@ -3341,6 +3346,8 @@
 			BigDecimal val;
 
 			if (stringVal != null) {
+				this.wasNullFlag = false;
+				
 				if (stringVal.length() == 0) {
 					val = new BigDecimal(0);
 
@@ -3364,6 +3371,8 @@
 				return val.toString();
 			}
 
+			this.wasNullFlag = true;
+			
 			return null;
 
 		case Types.CHAR:
@@ -5058,9 +5067,10 @@
 	 */
 	public short getShort(int columnIndex) throws SQLException {
 		if (!this.isBinaryEncoded) {
+			checkRowPos();
+			
 			if (this.connection.getUseFastIntParsing()) {
-				checkRowPos();
-
+				
 				checkColumnBounds(columnIndex);
 				
 				try {

Modified: branches/branch_5_0/connector-j/src/com/mysql/jdbc/Statement.java
===================================================================
--- branches/branch_5_0/connector-j/src/com/mysql/jdbc/Statement.java	2006-04-04 15:53:24 UTC (rev 5133)
+++ branches/branch_5_0/connector-j/src/com/mysql/jdbc/Statement.java	2006-04-04 19:47:49 UTC (rev 5134)
@@ -1029,12 +1029,14 @@
 	 */
 	public java.sql.ResultSet executeQuery(String sql)
 			throws SQLException {
+		checkClosed();
+		
 		synchronized (this.connection.getMutex()) {
 			this.wasCancelled = false;
 	
 			checkNullOrEmptyQuery(sql);
 	
-			checkClosed();
+			
 	
 			if (this.doEscapeProcessing) {
 				Object escapedSqlResult = EscapeProcessor.escapeSQL(sql,
@@ -1205,29 +1207,28 @@
 
 	protected int executeUpdate(String sql, boolean isBatch)
 			throws SQLException {
-
+		checkClosed();
+		
 		char firstStatementChar = StringUtils.firstNonWsCharUc(sql);
 
-		if (this.doEscapeProcessing) {
-			Object escapedSqlResult = EscapeProcessor.escapeSQL(sql,
-					this.connection.serverSupportsConvertFn(), this.connection);
-
-			if (escapedSqlResult instanceof String) {
-				sql = (String) escapedSqlResult;
-			} else {
-				sql = ((EscapeProcessorResult) escapedSqlResult).escapedSql;
-			}
-		}
-
 		ResultSet rs = null;
 
 		synchronized (this.connection.getMutex()) {
 			this.wasCancelled = false;
 	
 			checkNullOrEmptyQuery(sql);
-	
-			checkClosed();
-	
+
+			if (this.doEscapeProcessing) {
+				Object escapedSqlResult = EscapeProcessor.escapeSQL(sql,
+						this.connection.serverSupportsConvertFn(), this.connection);
+
+				if (escapedSqlResult instanceof String) {
+					sql = (String) escapedSqlResult;
+				} else {
+					sql = ((EscapeProcessorResult) escapedSqlResult).escapedSql;
+				}
+			}
+			
 			if (this.connection.isReadOnly()) {
 				throw SQLError.createSQLException(Messages
 						.getString("Statement.42") //$NON-NLS-1$

Modified: branches/branch_5_0/connector-j/src/com/mysql/jdbc/UpdatableResultSet.java
===================================================================
--- branches/branch_5_0/connector-j/src/com/mysql/jdbc/UpdatableResultSet.java	2006-04-04 15:53:24 UTC (rev 5133)
+++ branches/branch_5_0/connector-j/src/com/mysql/jdbc/UpdatableResultSet.java	2006-04-04 19:47:49 UTC (rev 5134)
@@ -1026,6 +1026,10 @@
 	 *             if an error occurs.
 	 */
 	protected void realClose(boolean calledExplicitly) throws SQLException {
+		if (this.isClosed) {
+			return;
+		}
+		
 		SQLException sqlEx = null;
 
 		if (this.useUsageAdvisor) {
@@ -2289,6 +2293,8 @@
 	 */
 	public synchronized void updateString(int columnIndex, String x)
 			throws SQLException {
+		checkClosed();
+		
 		if (!this.onInsertRow) {
 			if (!this.doingUpdates) {
 				this.doingUpdates = true;

Thread
Connector/J commit: r5134 - branches/branch_5_0/connector-j/src/com/mysql/jdbcmmatthews4 Apr