Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use vertx-mysql-postgresql-client-3.4.1 query MySQL 5.7.8(or later) Json Data failed #97

Open
ordiy opened this issue Dec 22, 2017 · 4 comments

Comments

@ordiy
Copy link

ordiy commented Dec 22, 2017

I use vertx-mysql-client query data from mySQL5.7.8,have an error
my dependency :

<dependency>     
  <groupId>io.vertx</groupId>    
  <artifactId>vertx-mysql-postgresql-client</artifactId>     
  <version>3.4.1</version>    
</dependency>     

my code:

 //set time out
        long timerId = this.vertx.setTimer(3000, ars -> {
            if (!future.isComplete()) {
                log.error("{} query MySQL time out ,sql:{},data:{}", reqId, querySql, params);
            }
        });

        this.mySQLClient.getConnection(res -> {
            if (res.succeeded()) {
                SQLConnection cnn = res.result();
                cnn.queryWithParams(querySql, params, dbRes -> {
                    cnn.close();
                    if (dbRes.succeeded()) {
                        ResultSet result = dbRes.result();
                        List<JsonObject> rows = result.getRows();
                        JsonObject oneRow = rows.stream().findFirst().orElse(null);
                        if (oneRow != null) {
                            System.out.println(oneRow.getJsonObject("extras")); // hava error
                        }
                    } else {
                        //cause
                    }
                });
            } else {
                //cause
            }
        });

error log:

2017-12-21 14:45:23.153 [vert.x-eventloop-thread-5] ERROR c.g.m.a.d.m.MySQLConnection:119- Transport failure 
scala.MatchError: 245 (of class java.lang.Integer)
	at com.github.mauricio.async.db.mysql.codec.DecoderRegistry.binaryDecoderFor(DecoderRegistry.scala:37)
	at com.github.mauricio.async.db.mysql.decoder.ColumnDefinitionDecoder.decode(ColumnDefinitionDecoder.scala:63)
	at com.github.mauricio.async.db.mysql.codec.MySQLFrameDecoder.decodeQueryResult(MySQLFrameDecoder.scala:234)
	at com.github.mauricio.async.db.mysql.codec.MySQLFrameDecoder.doDecoding(MySQLFrameDecoder.scala:163)
	at com.github.mauricio.async.db.mysql.codec.MySQLFrameDecoder.handleCommonFlow(MySQLFrameDecoder.scala:157)
	at com.github.mauricio.async.db.mysql.codec.MySQLFrameDecoder.decode(MySQLFrameDecoder.scala:90)
	at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:411)
	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:248)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:363)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:349)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:341)
	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1334)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:363)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:349)
	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:926)
	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:129)
	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:642)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:565)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:479)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:441)
	at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858)
	at java.lang.Thread.run(Thread.java:748)
2017-12-21 14:45:23.155 [vert.x-eventloop-thread-3] ERROR c.j.d.p.c.GetPermissionInfoHandler:53- get_permission_info failed,causeL:

MySQL tables desc info:

Field Type Null Key Default Extra
id int(11) NO PRI NULL auto_increment
dev_id int(11) NO MUL NULL
dev_key varchar(64) NO MUL NULL
api_key varchar(64) NO NULL
start_time timestamp YES CURRENT_TIMESTAMP
end_time timestamp YES CURRENT_TIMESTAMP
total_times int(11) YES NULL
frequency_times int(11) YES NULL
frequency_unit int(11) YES NULL
extras json YES NULL

the create table sql:

 CREATE TABLE `t_api_auth` (
  `id` int(11) NOT NULL AUTO_INCREMENT ,
  `dev_id` int(11) NOT NULL ,
  `dev_key` varchar(64) NOT NULL  ,
  `api_key` varchar(64) NOT NULL  ,
  `start_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP  ,
  `end_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP  ,
  `total_times` int(11) DEFAULT NULL  ,
  `frequency_times` int(11) DEFAULT NULL ,
  `frequency_unit` int(11) DEFAULT NULL  ,
  `extras` json DEFAULT NULL  ,
  `billing_period` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=839 DEFAULT CHARSET=utf8;

I want to try to Solve this problem,but my Scale program is bad.

@ordiy
Copy link
Author

ordiy commented Dec 22, 2017

but I use vertx-jdbc-client slove this error.

@juanavelez
Copy link
Contributor

This might not be the actual cause of the error but it seems strange you close the connection BEFORE you read the results. Have you tried closing the connection AFTER you have read the results?

@iheng-scau
Copy link

if getting rid of the json columns, the exception never be raised. It seems that the problem lays on this client does not support json column query.

@andy-yx-chen
Copy link
Contributor

it is! mauricio is buggy, and not longer supported, try https://github.com/andy-yx-chen/vertx-mysql-postgresql-client this one and if it still fails, try to contact jasync-sql project and ask them to fix the bug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants