可有抓包工具可以抓取Java Client与Mysql Server之间通信的数据

zgw06629 发布于 2015/05/07 22:15
阅读 1K+
收藏 0

Jdbc创建连接过程中,在某几处加了断点,于是就一直报错:

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet successfully received from the server was 118 milliseconds ago.  The last packet sent successfully to the server was 12 milliseconds ago.

找了半天也没找到到底在哪设置的超时,于是想能否通过抓包工具,来查看Java client 与Mysql Server之间的通信数据.因为单单看query log的话,信息量太少了,如建立连接看到的只有这么一个简单的输出:

150507 21:58:10	   22 Connect	root@localhost on



加载中
0
zgw06629
zgw06629

Ubuntu系统中使用Wireshark倒是挺方便,jdbc 代码:

String url = "jdbc:mysql://localhost:3306";
Connection conn = java.sql.DriverManager.getConnection(url , user, password);
Statement stmt = conn.createStatement();
String sql = "select 'hello';select 'world'";
stmt.execute(sql);

使用Wireshark抓包截图:

0
eechen
eechen
Linux上确实很方便使用WireShark监听本地loopback的服务,比如分析PHP的mysqli绑定参数查询的网络通信过程:

$mysqli = new mysqli("127.0.0.1", "user", "pass", "punbb");
$query = "SELECT `username` FROM `pb_users` WHERE `id`=?";
$stmt = $mysqli->prepare($query);
$stmt->bind_param('i', $id);
$id = "2";
$stmt->execute();
$stmt->store_result();
$stmt->bind_result($name);
while ($stmt->fetch()) echo $name;
$stmt->close();
$mysqli->close();

返回顶部
顶部