[teiid-commits] teiid SVN: r3763 - branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Tue Jan 3 14:40:58 EST 2012


Author: jolee
Date: 2012-01-03 14:40:57 -0500 (Tue, 03 Jan 2012)
New Revision: 3763

Modified:
   branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQL5ExecutionFactory.java
Log:
SOA-3683 / TEIID-1871 Teiid is handling MySQL5.0 returning DAYNAME as a blob

Modified: branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQL5ExecutionFactory.java
===================================================================
--- branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQL5ExecutionFactory.java	2012-01-03 17:20:39 UTC (rev 3762)
+++ branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQL5ExecutionFactory.java	2012-01-03 19:40:57 UTC (rev 3763)
@@ -1,69 +1,94 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
 package org.teiid.translator.jdbc.mysql;
 
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.teiid.language.Function;
-import org.teiid.translator.Translator;
-import org.teiid.translator.TranslatorException;
-import org.teiid.translator.SourceSystemFunctions;
-import org.teiid.translator.jdbc.FunctionModifier;
-
- at Translator(name="mysql5", description="A translator for open source MySQL5 Database")
-public class MySQL5ExecutionFactory extends MySQLExecutionFactory {
-	
-	@Override
-    public void start() throws TranslatorException {
-        super.start();
-        registerFunctionModifier(SourceSystemFunctions.CHAR, new FunctionModifier() {
-			
-			@Override
-			public List<?> translate(Function function) {
-				return Arrays.asList("char(", function.getParameters().get(0), " USING ASCII)"); //$NON-NLS-1$ //$NON-NLS-2$
-			}
-		});
+import java.sql.Blob;
+import java.sql.CallableStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.teiid.language.Function;
+import org.teiid.translator.SourceSystemFunctions;
+import org.teiid.translator.Translator;
+import org.teiid.translator.TranslatorException;
+import org.teiid.translator.TypeFacility;
+import org.teiid.translator.jdbc.FunctionModifier;
+
+ at Translator(name="mysql5", description="A translator for open source MySQL5 Database")
+public class MySQL5ExecutionFactory extends MySQLExecutionFactory {
+	
+	@Override
+    public void start() throws TranslatorException {
+        super.start();
+        registerFunctionModifier(SourceSystemFunctions.CHAR, new FunctionModifier() {
+			
+			@Override
+			public List<?> translate(Function function) {
+				return Arrays.asList("char(", function.getParameters().get(0), " USING ASCII)"); //$NON-NLS-1$ //$NON-NLS-2$
+			}
+		});
 	}
-	
-	@Override
-    public List<String> getSupportedFunctions() {
-        List<String> supportedFunctions = new ArrayList<String>();
-        supportedFunctions.addAll(super.getSupportedFunctions());
-        supportedFunctions.add(SourceSystemFunctions.TIMESTAMPADD);
-        supportedFunctions.add(SourceSystemFunctions.TIMESTAMPDIFF);
-        return supportedFunctions;
-    }
-    
-    @Override
-    public boolean supportsInlineViews() {
-    	return true;
-    }
-    
-    @Override
-    public boolean supportsAggregatesEnhancedNumeric() {
-    	return true;
-    }
-	
+	
+	@Override
+    public List<String> getSupportedFunctions() {
+        List<String> supportedFunctions = new ArrayList<String>();
+        supportedFunctions.addAll(super.getSupportedFunctions());
+        supportedFunctions.add(SourceSystemFunctions.TIMESTAMPADD);
+        supportedFunctions.add(SourceSystemFunctions.TIMESTAMPDIFF);
+        return supportedFunctions;
+    }
+    
+    @Override
+    public boolean supportsInlineViews() {
+    	return true;
+    }
+    
+    @Override
+    public boolean supportsAggregatesEnhancedNumeric() {
+    	return true;
+    }
+    
+    @Override
+    public Object retrieveValue(ResultSet results, int columnIndex,
+    		Class<?> expectedType) throws SQLException {
+    	Object result = super.retrieveValue(results, columnIndex, expectedType);
+    	if (expectedType == TypeFacility.RUNTIME_TYPES.STRING && result instanceof Blob) {
+    		return results.getString(columnIndex);
+    	}
+    	return result;
+    }
+    
+    @Override
+    public Object retrieveValue(CallableStatement results, int parameterIndex,
+    		Class<?> expectedType) throws SQLException {
+    	Object result = super.retrieveValue(results, parameterIndex, expectedType);
+    	if (expectedType == TypeFacility.RUNTIME_TYPES.STRING && result instanceof Blob) {
+    		return results.getString(parameterIndex);
+    	}
+    	return result;
+    }
+    
 }



More information about the teiid-commits mailing list