提交 47a78927 编写于 作者: Z zyyang

[TD-3222]<fix>: fix JNI connection failover bugs in jdbcdriver

上级 8f5820fd
...@@ -4,7 +4,6 @@ import org.junit.Test; ...@@ -4,7 +4,6 @@ import org.junit.Test;
import java.sql.*; import java.sql.*;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
public class FailOverTest { public class FailOverTest {
...@@ -18,13 +17,17 @@ public class FailOverTest { ...@@ -18,13 +17,17 @@ public class FailOverTest {
long end = System.currentTimeMillis() + 1000 * 60 * 5; long end = System.currentTimeMillis() + 1000 * 60 * 5;
while (System.currentTimeMillis() < end) { while (System.currentTimeMillis() < end) {
try (Connection conn = DriverManager.getConnection(url)) { try (Connection conn = DriverManager.getConnection(url); Statement stmt = conn.createStatement()) {
Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery("show dnodes()");
ResultSet resultSet = stmt.executeQuery("select server_status()"); ResultSetMetaData meta = rs.getMetaData();
resultSet.next(); while (rs.next()) {
int status = resultSet.getInt("server_status()"); for (int i = 1; i <= meta.getColumnCount(); i++) {
System.out.println(">>>>>>>>>" + sdf.format(new Date()) + " status : " + status); System.out.print(meta.getColumnLabel(i) + ": " + rs.getString(i) + "\t");
stmt.close(); }
System.out.println();
}
System.out.println("=======================");
rs.close();
TimeUnit.SECONDS.sleep(5); TimeUnit.SECONDS.sleep(5);
} catch (SQLException | InterruptedException e) { } catch (SQLException | InterruptedException e) {
e.printStackTrace(); e.printStackTrace();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册