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

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

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