MCPcopy Create free account
hub / github.com/e2wugui/zeze / mainTestPolarDb1

Method mainTestPolarDb1

ZezeJava/ZezeJavaTest/src/Temp/Bench1Mysql.java:53–91  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

51 }
52
53 public static void mainTestPolarDb1(String[] args) throws Exception {
54 try (var dataSource = new DruidDataSource()) {
55 dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver");
56 dataSource.setUrl("jdbc:mysql://localhost/devtest?user=dev&password=devtest12345&useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true");
57
58 try (var connection = dataSource.getConnection()) {
59 connection.setAutoCommit(true);
60
61 var dropSql = "DROP PROCEDURE IF EXISTS TestProc1;";
62 try (var cmd = connection.prepareStatement(dropSql)) {
63 cmd.executeUpdate();
64 }
65
66 var procSql = "CREATE PROCEDURE TestProc1(IN in_data BINARY, OUT out_data BINARY, OUT out_hex VARCHAR)\n" +
67 "BEGIN\n" +
68 " SET out_data = in_data;\n" +
69 " SET out_hex = hex(in_data);\n" +
70 "END;";
71 try (var cmd = connection.prepareStatement(procSql)) {
72 cmd.executeUpdate();
73 }
74
75 try (var cmd = connection.prepareCall("CALL TestProc1(?,?,?)")) {
76 cmd.setBytes(1, new byte[]{(byte)0xa4}); // data
77 cmd.registerOutParameter(2, Types.BINARY);
78 cmd.registerOutParameter(3, Types.VARCHAR);
79 cmd.executeUpdate();
80 var data = cmd.getBytes(2);
81 //var data = blob.getBytes(1, (int)blob.length());
82 System.out.print("out_data =");
83 for (byte b : data)
84 System.out.format(" %02X", b & 0xff);
85 System.out.println();
86 System.out.println("out_hex = " + cmd.getString(3));
87 }
88 }
89 }
90 System.out.println("OK!");
91 }
92
93 public static void mainTestPolarDb2(String[] args) throws Exception {
94 try (var dataSource = new DruidDataSource()) {

Callers

nothing calls this directly

Calls 4

formatMethod · 0.80
getBytesMethod · 0.65
printMethod · 0.45
getStringMethod · 0.45

Tested by

no test coverage detected