Author: shawkins
Date: 2009-04-16 13:33:22 -0400 (Thu, 16 Apr 2009)
New Revision: 787
Modified:
trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMCallableStatement.java
trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMDatabaseMetaData.java
trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMPreparedStatement.java
trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMStatement.java
trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMStatement.java
Log:
TEIID-495 correcting the regression that prevents statement batched updates.
Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMCallableStatement.java
===================================================================
---
trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMCallableStatement.java 2009-04-16
16:26:10 UTC (rev 786)
+++
trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMCallableStatement.java 2009-04-16
17:33:22 UTC (rev 787)
@@ -84,8 +84,7 @@
@Override
protected RequestMessage createRequestMessage(String[] commands,
- boolean isBatchedCommand, Boolean requiresResultSet)
- throws MMSQLException {
+ boolean isBatchedCommand, Boolean requiresResultSet) {
RequestMessage message = super.createRequestMessage(commands, isBatchedCommand,
requiresResultSet);
message.setCallableStatement(true);
message.setPreparedStatement(false);
Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMDatabaseMetaData.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMDatabaseMetaData.java 2009-04-16
16:26:10 UTC (rev 786)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMDatabaseMetaData.java 2009-04-16
17:33:22 UTC (rev 787)
@@ -125,46 +125,10 @@
public final static String JDBC_SYSTEM_MODEL_NAME = "System.JDBC";
//$NON-NLS-1$
}
- // decodeString mappings
private static final String TYPE_MAPPING;
-// new StringBuffer( MMJDBCSQLTypeInfo.STRING)
.append(",").append(MMJDBCSQLTypeInfo.getSQLType(MMJDBCSQLTypeInfo.STRING))
//$NON-NLS-1$
-// .append(",").append(MMJDBCSQLTypeInfo.INTEGER)
.append(",").append(MMJDBCSQLTypeInfo.getSQLType(MMJDBCSQLTypeInfo.INTEGER))
//$NON-NLS-1$ //$NON-NLS-2$
-// .append(",").append(MMJDBCSQLTypeInfo.BOOLEAN)
.append(",").append(MMJDBCSQLTypeInfo.getSQLType(MMJDBCSQLTypeInfo.BOOLEAN))
//$NON-NLS-1$ //$NON-NLS-2$
-// .append(",").append(MMJDBCSQLTypeInfo.DATE)
.append(",").append(MMJDBCSQLTypeInfo.getSQLType(MMJDBCSQLTypeInfo.DATE))
//$NON-NLS-1$ //$NON-NLS-2$
-// .append(",").append(MMJDBCSQLTypeInfo.TIME)
.append(",").append(MMJDBCSQLTypeInfo.getSQLType(MMJDBCSQLTypeInfo.TIME))
//$NON-NLS-1$ //$NON-NLS-2$
-// .append(",").append(MMJDBCSQLTypeInfo.TIMESTAMP)
.append(",").append(MMJDBCSQLTypeInfo.getSQLType(MMJDBCSQLTypeInfo.TIMESTAMP))
//$NON-NLS-1$ //$NON-NLS-2$
-// .append(",").append(MMJDBCSQLTypeInfo.DOUBLE)
.append(",").append(MMJDBCSQLTypeInfo.getSQLType(MMJDBCSQLTypeInfo.DOUBLE))
//$NON-NLS-1$ //$NON-NLS-2$
-// .append(",").append(MMJDBCSQLTypeInfo.FLOAT)
.append(",").append(MMJDBCSQLTypeInfo.getSQLType(MMJDBCSQLTypeInfo.FLOAT))
//$NON-NLS-1$ //$NON-NLS-2$
-// .append(",").append(MMJDBCSQLTypeInfo.BIGDECIMAL)
.append(",").append(MMJDBCSQLTypeInfo.getSQLType(MMJDBCSQLTypeInfo.BIGDECIMAL))
//$NON-NLS-1$ //$NON-NLS-2$
-// .append(",").append(MMJDBCSQLTypeInfo.BYTE)
.append(",").append(MMJDBCSQLTypeInfo.getSQLType(MMJDBCSQLTypeInfo.BYTE))
//$NON-NLS-1$ //$NON-NLS-2$
-// .append(",").append(MMJDBCSQLTypeInfo.SHORT)
.append(",").append(MMJDBCSQLTypeInfo.getSQLType(MMJDBCSQLTypeInfo.SHORT))
//$NON-NLS-1$ //$NON-NLS-2$
-// .append(",").append(MMJDBCSQLTypeInfo.LONG)
.append(",").append(MMJDBCSQLTypeInfo.getSQLType(MMJDBCSQLTypeInfo.LONG))
//$NON-NLS-1$ //$NON-NLS-2$
-// .append(",").append(MMJDBCSQLTypeInfo.CLOB)
.append(",").append(MMJDBCSQLTypeInfo.getSQLType(MMJDBCSQLTypeInfo.CLOB))
//$NON-NLS-1$ //$NON-NLS-2$
-// .append(",").append(MMJDBCSQLTypeInfo.BLOB)
.append(",").append(MMJDBCSQLTypeInfo.getSQLType(MMJDBCSQLTypeInfo.BLOB))
//$NON-NLS-1$ //$NON-NLS-2$
-// .append(",").append(MMJDBCSQLTypeInfo.BIGINTEGER)
.append(",").append(MMJDBCSQLTypeInfo.getSQLType(MMJDBCSQLTypeInfo.BIGINTEGER))
//$NON-NLS-1$ //$NON-NLS-2$
-// .append(",").append(MMJDBCSQLTypeInfo.CHAR)
.append(",").append(MMJDBCSQLTypeInfo.getSQLType(MMJDBCSQLTypeInfo.CHAR))
//$NON-NLS-1$ //$NON-NLS-2$
-// .append(",").append(MMJDBCSQLTypeInfo.OBJECT)
.append(",").append(MMJDBCSQLTypeInfo.getSQLType(MMJDBCSQLTypeInfo.OBJECT))
//$NON-NLS-1$ //$NON-NLS-2$
-// .toString();
private static final String PRECISION_MAPPING;
-// new StringBuffer( MMJDBCSQLTypeInfo.STRING)
.append(",").append(ResultsMetadataDefaults.getDefaultPrecision(MMJDBCSQLTypeInfo.STRING))
//$NON-NLS-1$
-// .append(",").append(MMJDBCSQLTypeInfo.INTEGER)
.append(",").append(ResultsMetadataDefaults.getDefaultPrecision(MMJDBCSQLTypeInfo.INTEGER))
//$NON-NLS-1$ //$NON-NLS-2$
-// .append(",").append(MMJDBCSQLTypeInfo.BOOLEAN)
.append(",").append(ResultsMetadataDefaults.getDefaultPrecision(MMJDBCSQLTypeInfo.BOOLEAN))
//$NON-NLS-1$ //$NON-NLS-2$
-// .append(",").append(MMJDBCSQLTypeInfo.DATE)
.append(",").append(ResultsMetadataDefaults.getDefaultPrecision(MMJDBCSQLTypeInfo.DATE))
//$NON-NLS-1$ //$NON-NLS-2$
-// .append(",").append(MMJDBCSQLTypeInfo.TIME)
.append(",").append(ResultsMetadataDefaults.getDefaultPrecision(MMJDBCSQLTypeInfo.TIME))
//$NON-NLS-1$ //$NON-NLS-2$
-// .append(",").append(MMJDBCSQLTypeInfo.TIMESTAMP)
.append(",").append(ResultsMetadataDefaults.getDefaultPrecision(MMJDBCSQLTypeInfo.TIMESTAMP))
//$NON-NLS-1$ //$NON-NLS-2$
-// .append(",").append(MMJDBCSQLTypeInfo.DOUBLE)
.append(",").append(ResultsMetadataDefaults.getDefaultPrecision(MMJDBCSQLTypeInfo.DOUBLE))
//$NON-NLS-1$ //$NON-NLS-2$
-// .append(",").append(MMJDBCSQLTypeInfo.FLOAT)
.append(",").append(ResultsMetadataDefaults.getDefaultPrecision(MMJDBCSQLTypeInfo.FLOAT))
//$NON-NLS-1$ //$NON-NLS-2$
-// .append(",").append(MMJDBCSQLTypeInfo.BIGDECIMAL)
.append(",").append(ResultsMetadataDefaults.getDefaultPrecision(MMJDBCSQLTypeInfo.BIGDECIMAL))
//$NON-NLS-1$ //$NON-NLS-2$
-// .append(",").append(MMJDBCSQLTypeInfo.BYTE)
.append(",").append(ResultsMetadataDefaults.getDefaultPrecision(MMJDBCSQLTypeInfo.BYTE))
//$NON-NLS-1$ //$NON-NLS-2$
-// .append(",").append(MMJDBCSQLTypeInfo.SHORT)
.append(",").append(ResultsMetadataDefaults.getDefaultPrecision(MMJDBCSQLTypeInfo.SHORT))
//$NON-NLS-1$ //$NON-NLS-2$
-// .append(",").append(MMJDBCSQLTypeInfo.LONG)
.append(",").append(ResultsMetadataDefaults.getDefaultPrecision(MMJDBCSQLTypeInfo.LONG))
//$NON-NLS-1$ //$NON-NLS-2$
-// .append(",").append(MMJDBCSQLTypeInfo.CLOB)
.append(",").append(ResultsMetadataDefaults.getDefaultPrecision(MMJDBCSQLTypeInfo.CLOB))
//$NON-NLS-1$ //$NON-NLS-2$
-// .append(",").append(MMJDBCSQLTypeInfo.BLOB)
.append(",").append(ResultsMetadataDefaults.getDefaultPrecision(MMJDBCSQLTypeInfo.BLOB))
//$NON-NLS-1$ //$NON-NLS-2$
-// .append(",").append(MMJDBCSQLTypeInfo.BIGINTEGER)
.append(",").append(ResultsMetadataDefaults.getDefaultPrecision(MMJDBCSQLTypeInfo.BIGINTEGER))
//$NON-NLS-1$ //$NON-NLS-2$
-// .append(",").append(MMJDBCSQLTypeInfo.CHAR)
.append(",").append(ResultsMetadataDefaults.getDefaultPrecision(MMJDBCSQLTypeInfo.CHAR))
//$NON-NLS-1$ //$NON-NLS-2$
-// .append(",").append(MMJDBCSQLTypeInfo.OBJECT)
.append(",").append(ResultsMetadataDefaults.getDefaultPrecision(MMJDBCSQLTypeInfo.OBJECT))
//$NON-NLS-1$ //$NON-NLS-2$
-// .toString();
+
static {
String[] internalTypes = MMJDBCSQLTypeInfo.getMMTypeNames();
StringBuffer typeMapping = new StringBuffer();
Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMPreparedStatement.java
===================================================================
---
trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMPreparedStatement.java 2009-04-16
16:26:10 UTC (rev 786)
+++
trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMPreparedStatement.java 2009-04-16
17:33:22 UTC (rev 787)
@@ -201,8 +201,7 @@
@Override
protected RequestMessage createRequestMessage(String[] commands,
- boolean isBatchedCommand, Boolean requiresResultSet)
- throws MMSQLException {
+ boolean isBatchedCommand, Boolean requiresResultSet) {
RequestMessage message = super.createRequestMessage(commands, false,
requiresResultSet);
message.setPreparedStatement(true);
message.setParameterValues(isBatchedCommand?getParameterValuesList():
getParameterValues());
Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMStatement.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMStatement.java 2009-04-16
16:26:10 UTC (rev 786)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMStatement.java 2009-04-16
17:33:22 UTC (rev 787)
@@ -32,7 +32,6 @@
import java.sql.SQLFeatureNotSupportedException;
import java.sql.SQLWarning;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Calendar;
import java.util.Collection;
import java.util.HashMap;
@@ -443,11 +442,7 @@
}
protected RequestMessage createRequestMessage(String[] commands,
- boolean isBatchedCommand, Boolean requiresResultSet)
- throws MMSQLException {
- if (isBatchedCommand || requiresResultSet == Boolean.FALSE) {
- throw new
MMSQLException(JDBCPlugin.Util.getString("MMStatement.Operation_Not_Supported",
Arrays.asList(commands))); //$NON-NLS-1$
- }
+ boolean isBatchedCommand, Boolean requiresResultSet) {
RequestMessage reqMessage = new RequestMessage();
reqMessage.setCommands(commands);
reqMessage.setBatchedUpdate(isBatchedCommand);
Modified: trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMStatement.java
===================================================================
--- trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMStatement.java 2009-04-16
16:26:10 UTC (rev 786)
+++ trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMStatement.java 2009-04-16
17:33:22 UTC (rev 787)
@@ -22,11 +22,20 @@
package com.metamatrix.jdbc;
+import static org.junit.Assert.*;
+
import java.sql.ResultSet;
+import java.util.Arrays;
+import java.util.List;
import org.junit.Test;
import org.mockito.Mockito;
+import com.metamatrix.dqp.client.ClientSideDQP;
+import com.metamatrix.dqp.client.ResultsFuture;
+import com.metamatrix.dqp.message.RequestMessage;
+import com.metamatrix.dqp.message.ResultsMessage;
+
public class TestMMStatement {
@Test(expected=MMSQLException.class) public void testUpdateException() throws Exception
{
@@ -34,4 +43,20 @@
statement.executeQuery("delete from table"); //$NON-NLS-1$
}
+ @Test public void testBatchExecution() throws Exception {
+ MMConnection conn = Mockito.mock(MMConnection.class);
+ ClientSideDQP dqp = Mockito.mock(ClientSideDQP.class);
+ ResultsFuture<ResultsMessage> results = new
ResultsFuture<ResultsMessage>();
+ Mockito.stub(dqp.executeRequest(Mockito.anyLong(),
(RequestMessage)Mockito.anyObject())).toReturn(results);
+ ResultsMessage rm = new ResultsMessage();
+ rm.setResults(new List<?>[] {Arrays.asList(1), Arrays.asList(2)});
+ rm.setUpdateResult(true);
+ results.getResultsReceiver().receiveResults(rm);
+ Mockito.stub(conn.getDQP()).toReturn(dqp);
+ MMStatement statement = new MMStatement(conn, ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY);
+ statement.addBatch("delete from table"); //$NON-NLS-1$
+ statement.addBatch("delete from table1"); //$NON-NLS-1$
+ assertTrue(Arrays.equals(new int[] {1, 2}, statement.executeBatch()));
+ }
+
}