use of io.shardingjdbc.proxy.backend.mysql.MySQLPacketQueryResult in project sharding-jdbc by shardingjdbc.
the class SQLExecuteBackendHandler method mergeDQLorDAL.
private List<DatabaseProtocolPacket> mergeDQLorDAL(final SQLStatement sqlStatement, final List<List<DatabaseProtocolPacket>> packets) {
List<QueryResult> queryResults = new ArrayList<>(packets.size());
for (List<DatabaseProtocolPacket> each : packets) {
// TODO replace to a common PacketQueryResult
queryResults.add(new MySQLPacketQueryResult(each));
}
MergedResult mergedResult;
try {
mergedResult = MergeEngineFactory.newInstance(ShardingRuleRegistry.getInstance().getShardingRule(), queryResults, sqlStatement).merge();
} catch (final SQLException ex) {
return Collections.<DatabaseProtocolPacket>singletonList(new ErrPacket(1, ex.getErrorCode(), "", ex.getSQLState(), ex.getMessage()));
}
return buildPackets(packets, mergedResult);
}
Aggregations