为什么mysql-connector-java会调用那么多查询?

时间:2017-03-14 14:26:50

标签: java mysql

我从日志中看到:

2017-03-14T14:20:11.500178Z 32239500 Connect    root@localhost on livingcost using TCP/IP
2017-03-14T14:20:11.500639Z 32239500 Query  /* mysql-connector-java-5.1.23 ( Revision: ${bzr.revision-id} ) */SHOW VARIABLES WHERE Variable_name ='language' OR Variable_name = 'net_write_timeout' OR Variable_name = 'interactive_timeout' OR Variable_name = 'wait_timeout' OR Variable_name = 'character_set_client' OR Variable_name = 'character_set_connection' OR Variable_name = 'character_set' OR Variable_name = 'character_set_server' OR Variable_name = 'tx_isolation' OR Variable_name = 'transaction_isolation' OR Variable_name = 'character_set_results' OR Variable_name = 'timezone' OR Variable_name = 'time_zone' OR Variable_name = 'system_time_zone' OR Variable_name = 'lower_case_table_names' OR Variable_name = 'max_allowed_packet' OR Variable_name = 'net_buffer_length' OR Variable_name = 'sql_mode' OR Variable_name = 'query_cache_type' OR Variable_name = 'query_cache_size' OR Variable_name = 'init_connect'
2017-03-14T14:20:11.504557Z 32239500 Query  /* mysql-connector-java-5.1.23 ( Revision: ${bzr.revision-id} ) */SELECT @@session.auto_increment_increment
2017-03-14T14:20:11.504934Z 32239500 Query  SHOW COLLATION
2017-03-14T14:20:11.506885Z 32239500 Query  SHOW CHARACTER SET
2017-03-14T14:20:11.507591Z 32239500 Query  SET NAMES utf8
2017-03-14T14:20:11.507900Z 32239500 Query  SET character_set_results = NULL
2017-03-14T14:20:11.508181Z 32239500 Query  SET autocommit=1
2017-03-14T14:20:11.508537Z 32239500 Query  select @@session.tx_read_only
2017-03-14T14:20:11.508944Z 32239500 Query  select count(*) from community_members where ip_address_str = '92.18.29.143' and month = 3 and year = 2017
2017-03-14T14:20:11.509149Z 32239500 Quit   
2017-03-14T14:20:11.758158Z 32239501 Connect    root@localhost on livingcost using TCP/IP
2017-03-14T14:20:11.764438Z 32239501 Query  /* mysql-connector-java-5.1.23 ( Revision: ${bzr.revision-id} ) */SHOW VARIABLES WHERE Variable_name ='language' OR Variable_name = 'net_write_timeout' OR Variable_name = 'interactive_timeout' OR Variable_name = 'wait_timeout' OR Variable_name = 'character_set_client' OR Variable_name = 'character_set_connection' OR Variable_name = 'character_set' OR Variable_name = 'character_set_server' OR Variable_name = 'tx_isolation' OR Variable_name = 'transaction_isolation' OR Variable_name = 'character_set_results' OR Variable_name = 'timezone' OR Variable_name = 'time_zone' OR Variable_name = 'system_time_zone' OR Variable_name = 'lower_case_table_names' OR Variable_name = 'max_allowed_packet' OR Variable_name = 'net_buffer_length' OR Variable_name = 'sql_mode' OR Variable_name = 'query_cache_type' OR Variable_name = 'query_cache_size' OR Variable_name = 'init_connect'
2017-03-14T14:20:11.768286Z 32239501 Query  /* mysql-connector-java-5.1.23 ( Revision: ${bzr.revision-id} ) */SELECT @@session.auto_increment_increment
2017-03-14T14:20:11.768557Z 32239501 Query  SHOW COLLATION
2017-03-14T14:20:11.771081Z 32239501 Query  SHOW CHARACTER SET
2017-03-14T14:20:11.771665Z 32239501 Query  SET NAMES utf8
2017-03-14T14:20:11.771832Z 32239501 Query  SET character_set_results = NULL
2017-03-14T14:20:11.771979Z 32239501 Query  SET autocommit=1
2017-03-14T14:20:11.772211Z 32239501 Query  select id, email_address, subject, textMessage, htmlMessage from email_queue order by id limit 20
2017-03-14T14:20:11.772301Z 32239501 Quit   
2017-03-14T14:20:11.773789Z 32239502 Connect    root@localhost on livingcost using TCP/IP
2017-03-14T14:20:11.774101Z 32239502 Query  /* mysql-connector-java-5.1.23 ( Revision: ${bzr.revision-id} ) */SHOW VARIABLES WHERE Variable_name ='language' OR Variable_name = 'net_write_timeout' OR Variable_name = 'interactive_timeout' OR Variable_name = 'wait_timeout' OR Variable_name = 'character_set_client' OR Variable_name = 'character_set_connection' OR Variable_name = 'character_set' OR Variable_name = 'character_set_server' OR Variable_name = 'tx_isolation' OR Variable_name = 'transaction_isolation' OR Variable_name = 'character_set_results' OR Variable_name = 'timezone' OR Variable_name = 'time_zone' OR Variable_name = 'system_time_zone' OR Variable_name = 'lower_case_table_names' OR Variable_name = 'max_allowed_packet' OR Variable_name = 'net_buffer_length' OR Variable_name = 'sql_mode' OR Variable_name = 'query_cache_type' OR Variable_name = 'query_cache_size' OR Variable_name = 'init_connect'
2017-03-14T14:20:11.777956Z 32239502 Query  /* mysql-connector-java-5.1.23 ( Revision: ${bzr.revision-id} ) */SELECT @@session.auto_increment_increment
2017-03-14T14:20:11.778332Z 32239502 Query  SHOW COLLATION
2017-03-14T14:20:11.780162Z 32239502 Query  SHOW CHARACTER SET
2017-03-14T14:20:11.780754Z 32239502 Query  SET NAMES utf8
2017-03-14T14:20:11.780956Z 32239502 Query  SET character_set_results = NULL
2017-03-14T14:20:11.781145Z 32239502 Query  SET autocommit=1
2017-03-14T14:20:11.781451Z 32239502 Query  select @@session.tx_read_only
2017-03-14T14:20:11.781773Z 32239502 Query  select count(*) from community_members where ip_address_str = '184.94.21.114' and month = 3 and year = 2017
2017-03-14T14:20:11.782286Z 32239502 Quit   

我的应用程序不会调用大多数此类查询,例如

SHOW COLLATION

/* mysql-connector-java-5.1.23 ( Revision: ${bzr.revision-id} ) */SHOW VARIABLES WHERE Variable_name ='language' OR Variable_name = 'net_write_timeout' OR Variable_name = 'interactive_timeout' OR Variable_name = 'wait_timeout' OR Variable_name = 'character_set_client' OR Variable_name = 'character_set_connection' OR Variable_name = 'character_set' OR Variable_name = 'character_set_server' OR Variable_name = 'tx_isolation' OR Variable_name = 'transaction_isolation' OR Variable_name = 'character_set_results' OR Variable_name = 'timezone' OR Variable_name = 'time_zone' OR Variable_name = 'system_time_zone' OR Variable_name = 'lower_case_table_names' OR Variable_name = 'max_allowed_packet' OR Variable_name = 'net_buffer_length' OR Variable_name = 'sql_mode' OR Variable_name = 'query_cache_type' OR Variable_name = 'query_cache_size' OR Variable_name = 'init_connect'

SHOW CHARACTER SET

为什么mysql-connector-java会在日志中多次调用这些查询? 使用以下命令创建连接:

conn = DriverManager.getConnection(dbServer, dbUser, dbPass);

0 个答案:

没有答案