Repository: apache/shardingsphere
Issue: tinyint column don't return a 8-bit integer value but a boolean value

## Bug Report

**For English only**, other languages will not accept.

Before report a bug, make sure you have:

- Searched open and closed [GitHub issues](https://github.com/sharding-sphere/sharding-sphere/issues).
- Read documentation: [ShardingSphere Doc](http://shardingsphere.io/document/current/en/overview/).

Please pay attention on issues you submitted, because we maybe need more details. 
If no response **more than 7 days** and we cannot reproduce it on current information, we will **close it**.

Please answer these questions before submitting your issue. Thanks!

### Which version of ShardingSphere did you use?
4.0.0-RC1-SNAPSHOT
### Which project did you use? Sharding-JDBC or Sharding-Proxy?
Sharding-Proxy
### Expected behavior
When the column type is **tinyint**, return a 8-bit integer in MySQL protocol
### Actual behavior
When the column type is **tinyint**, return a boolean value in MySQL protocol
### Reason analyze (If you can)
JDBC's getObject() return a boolean value if the column occupy one byte.
### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
Any query SQL.
### Example codes for reproduce this issue (such as a github link).


Changed files:
sharding-jdbc/sharding-jdbc-core/src/test/java/org/apache/shardingsphere/shardingjdbc/executor/PreparedStatementExecutorTest.java
sharding-jdbc/sharding-jdbc-core/src/test/java/org/apache/shardingsphere/shardingjdbc/executor/StatementExecutorTest.java
sharding-core/sharding-core-execute/src/main/java/org/apache/shardingsphere/core/execute/sql/execute/result/StreamQueryResult.java

diff --git a/sharding-core/sharding-core-execute/src/main/java/org/apache/shardingsphere/core/execute/sql/execute/result/StreamQueryResult.java b/sharding-core/sharding-core-execute/src/main/java/org/apache/shardingsphere/core/execute/sql/execute/result/StreamQueryResult.java
index a7dcbb9b07c..ee8d6833be1 100644
--- a/sharding-core/sharding-core-execute/src/main/java/org/apache/shardingsphere/core/execute/sql/execute/result/StreamQueryResult.java
+++ b/sharding-core/sharding-core-execute/src/main/java/org/apache/shardingsphere/core/execute/sql/execute/result/StreamQueryResult.java
@@ -24,15 +24,9 @@ import org.apache.shardingsphere.core.rule.ShardingRule;
 import org.apache.shardingsphere.spi.encrypt.ShardingEncryptor;
 
 import java.io.InputStream;
-import java.io.Reader;
-import java.math.BigDecimal;
-import java.net.URL;
-import java.sql.Blob;
-import java.sql.Clob;
 import java.sql.Date;
 import java.sql.ResultSet;
 import java.sql.SQLException;
-import java.sql.SQLXML;
 import java.sql.Time;
 import java.sql.Timestamp;
 import java.util.Calendar;
@@ -74,96 +68,12 @@ public final class StreamQueryResult implements QueryResult {
     
     @Override
     public Object getValue(final int columnIndex, final Class<?> type) throws SQLException {
-        Object result;
-        if (Object.class == type) {
-            result = decrypt(columnIndex, resultSet.getObject(columnIndex));
-        } else if (boolean.class == type) {
-            result = decrypt(columnIndex, resultSet.getBoolean(columnIndex));
-        } else if (byte.class == type) {
-            result = decrypt(columnIndex, resultSet.getByte(columnIndex));
-        } else if (short.class == type) {
-            result = decrypt(columnIndex, resultSet.getShort(columnIndex));
-        } else if (int.class == type) {
-            result = decrypt(columnIndex, resultSet.getInt(columnIndex));
-        } else if (long.class == type) {
-            result = decrypt(columnIndex, resultSet.getLong(columnIndex));
-        } else if (float.class == type) {
-            result = decrypt(columnIndex, resultSet.getFloat(columnIndex));
-        } else if (double.class == type) {
-            result = decrypt(columnIndex, resultSet.getDouble(columnIndex));
-        } else if (String.class == type) {
-            result = decrypt(columnIndex, resultSet.getString(columnIndex));
-        } else if (BigDecimal.class == type) {
-            result = decrypt(columnIndex, resultSet.getBigDecimal(columnIndex));
-        } else if (byte[].class == type) {
-            result = resultSet.getBytes(columnIndex);
-        } else if (Date.class == type) {
-            result = resultSet.getDate(columnIndex);
-        } else if (Time.class == type) {
-            result = resultSet.getTime(columnIndex);
-        } else if (Timestamp.class == type) {
-            result = resultSet.getTimestamp(columnIndex);
-        } else if (URL.class == type) {
-            result = resultSet.getURL(columnIndex);
-        } else if (Blob.class == type) {
-            result = resultSet.getBlob(columnIndex);
-        } else if (Clob.class == type) {
-            result = resultSet.getClob(columnIndex);
-        } else if (SQLXML.class == type) {
-            result = resultSet.getSQLXML(columnIndex);
-        } else if (Reader.class == type) {
-            result = resultSet.getCharacterStream(columnIndex);
-        } else {
-            result = decrypt(columnIndex, resultSet.getObject(columnIndex));
-        }
-        return result;
+        return decrypt(columnIndex, QueryResultUtil.getValue(resultSet, columnIndex));
     }
     
     @Override
     public Object getValue(final String columnLabel, final Class<?> type) throws SQLException {
-        Object result;
-        if (Object.class == type) {
-            result = decrypt(columnLabel, resultSet.getObject(columnLabel));
-        } else if (boolean.class == type) {
-            result = decrypt(columnLabel, resultSet.getBoolean(columnLabel));
-        } else if (byte.class == type) {
-            result = decrypt(columnLabel, resultSet.getByte(columnLabel));
-        } else if (short.class == type) {
-            result = decrypt(columnLabel, resultSet.getShort(columnLabel));
-        } else if (int.class == type) {
-            result = decrypt(columnLabel, resultSet.getInt(columnLabel));
-        } else if (long.class == type) {
-            result = decrypt(columnLabel, resultSet.getLong(columnLabel));
-        } else if (float.class == type) {
-            result = decrypt(columnLabel, resultSet.getFloat(columnLabel));
-        } else if (double.class == type) {
-            result = decrypt(columnLabel, resultSet.getDouble(columnLabel));
-        } else if (String.class == type) {
-            result = decrypt(columnLabel, resultSet.getString(columnLabel));
-        } else if (BigDecimal.class == type) {
-            result = decrypt(columnLabel, resultSet.getBigDecimal(columnLabel));
-        } else if (byte[].class == type) {
-            result = resultSet.getBytes(columnLabel);
-        } else if (Date.class == type) {
-            result = resultSet.getDate(columnLabel);
-        } else if (Time.class == type) {
-            result = resultSet.getTime(columnLabel);
-        } else if (Timestamp.class == type) {
-            result = resultSet.getTimestamp(columnLabel);
-        } else if (URL.class == type) {
-            result = resultSet.getURL(columnLabel);
-        } else if (Blob.class == type) {
-            result = resultSet.getBlob(columnLabel);
-        } else if (Clob.class == type) {
-            result = resultSet.getClob(columnLabel);
-        } else if (SQLXML.class == type) {
-            result = resultSet.getSQLXML(columnLabel);
-        } else if (Reader.class == type) {
-            result = resultSet.getCharacterStream(columnLabel);
-        } else {
-            result = decrypt(columnLabel, resultSet.getObject(columnLabel));
-        }
-        return result;
+        return decrypt(columnLabel, QueryResultUtil.getValue(resultSet, metaData.getColumnIndex(columnLabel)));
     }
     
     @Override
diff --git a/sharding-jdbc/sharding-jdbc-core/src/test/java/org/apache/shardingsphere/shardingjdbc/executor/PreparedStatementExecutorTest.java b/sharding-jdbc/sharding-jdbc-core/src/test/java/org/apache/shardingsphere/shardingjdbc/executor/PreparedStatementExecutorTest.java
index f16b15b1de1..88a94151f73 100644
--- a/sharding-jdbc/sharding-jdbc-core/src/test/java/org/apache/shardingsphere/shardingjdbc/executor/PreparedStatementExecutorTest.java
+++ b/sharding-jdbc/sharding-jdbc-core/src/test/java/org/apache/shardingsphere/shardingjdbc/executor/PreparedStatementExecutorTest.java
@@ -34,6 +34,7 @@ import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.ResultSetMetaData;
 import java.sql.SQLException;
+import java.sql.Types;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
@@ -81,6 +82,7 @@ public final class PreparedStatementExecutorTest extends AbstractBaseExecutorTes
         when(resultSetMetaData.getColumnLabel(1)).thenReturn("column");
         when(resultSetMetaData.getTableName(1)).thenReturn("table_x");
         when(resultSetMetaData.getColumnCount()).thenReturn(1);
+        when(resultSetMetaData.getColumnType(1)).thenReturn(Types.VARCHAR);
         when(resultSet.getString(1)).thenReturn("value");
         when(resultSet.getMetaData()).thenReturn(resultSetMetaData);
         when(preparedStatement.executeQuery()).thenReturn(resultSet);
@@ -99,6 +101,7 @@ public final class PreparedStatementExecutorTest extends AbstractBaseExecutorTes
         when(resultSetMetaData.getColumnLabel(1)).thenReturn("column");
         when(resultSetMetaData.getTableName(1)).thenReturn("table_x");
         when(resultSetMetaData.getColumnCount()).thenReturn(1);
+        when(resultSetMetaData.getColumnType(1)).thenReturn(Types.INTEGER);
         when(resultSet1.getMetaData()).thenReturn(resultSetMetaData);
         when(resultSet2.getMetaData()).thenReturn(resultSetMetaData);
         when(resultSet1.getInt(1)).thenReturn(1);
diff --git a/sharding-jdbc/sharding-jdbc-core/src/test/java/org/apache/shardingsphere/shardingjdbc/executor/StatementExecutorTest.java b/sharding-jdbc/sharding-jdbc-core/src/test/java/org/apache/shardingsphere/shardingjdbc/executor/StatementExecutorTest.java
index 058a9a90112..068e7913aaa 100644
--- a/sharding-jdbc/sharding-jdbc-core/src/test/java/org/apache/shardingsphere/shardingjdbc/executor/StatementExecutorTest.java
+++ b/sharding-jdbc/sharding-jdbc-core/src/test/java/org/apache/shardingsphere/shardingjdbc/executor/StatementExecutorTest.java
@@ -35,6 +35,7 @@ import java.sql.ResultSet;
 import java.sql.ResultSetMetaData;
 import java.sql.SQLException;
 import java.sql.Statement;
+import java.sql.Types;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
@@ -82,6 +83,7 @@ public final class StatementExecutorTest extends AbstractBaseExecutorTest {
         when(resultSetMetaData.getColumnLabel(1)).thenReturn("column");
         when(resultSetMetaData.getTableName(1)).thenReturn("table_x");
         when(resultSetMetaData.getColumnCount()).thenReturn(1);
+        when(resultSetMetaData.getColumnType(1)).thenReturn(Types.VARCHAR);
         when(resultSet.getString(1)).thenReturn("value");
         when(resultSet.getMetaData()).thenReturn(resultSetMetaData);
         when(statement.executeQuery(DQL_SQL)).thenReturn(resultSet);
@@ -101,6 +103,7 @@ public final class StatementExecutorTest extends AbstractBaseExecutorTest {
         when(resultSetMetaData.getColumnLabel(1)).thenReturn("column");
         when(resultSetMetaData.getTableName(1)).thenReturn("table_x");
         when(resultSetMetaData.getColumnCount()).thenReturn(1);
+        when(resultSetMetaData.getColumnType(1)).thenReturn(Types.INTEGER);
         when(resultSet1.getMetaData()).thenReturn(resultSetMetaData);
         when(resultSet2.getMetaData()).thenReturn(resultSetMetaData);
         when(resultSet1.getInt(1)).thenReturn(1);