chore: remove tracked runtime artifacts
This commit is contained in:
Binary file not shown.
@@ -1,39 +0,0 @@
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.ResultSetMetaData;
|
||||
import java.sql.Statement;
|
||||
|
||||
public final class DbQuery {
|
||||
public static void main(String[] args) throws Exception {
|
||||
if (args.length < 2) {
|
||||
throw new IllegalArgumentException("usage: DbQuery <database> <sql>");
|
||||
}
|
||||
String url = "jdbc:mysql://127.0.0.1:3306/" + args[0]
|
||||
+ "?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai"
|
||||
+ "&useSSL=false&allowPublicKeyRetrieval=true";
|
||||
try (Connection connection = DriverManager.getConnection(url, "root", "123456");
|
||||
Statement statement = connection.createStatement()) {
|
||||
boolean hasResult = statement.execute(args[1]);
|
||||
if (!hasResult) {
|
||||
System.out.println("updateCount=" + statement.getUpdateCount());
|
||||
return;
|
||||
}
|
||||
try (ResultSet result = statement.getResultSet()) {
|
||||
ResultSetMetaData meta = result.getMetaData();
|
||||
for (int column = 1; column <= meta.getColumnCount(); column++) {
|
||||
if (column > 1) System.out.print("\t");
|
||||
System.out.print(meta.getColumnLabel(column));
|
||||
}
|
||||
System.out.println();
|
||||
while (result.next()) {
|
||||
for (int column = 1; column <= meta.getColumnCount(); column++) {
|
||||
if (column > 1) System.out.print("\t");
|
||||
System.out.print(String.valueOf(result.getObject(column)));
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user