| 123456789101112131415161718192021222324252627282930313233 |
- import java.sql.*;
- public class CheckRcCancel2 {
- public static void main(String[] args) throws Exception {
- Class.forName("oracle.jdbc.driver.OracleDriver");
- try (Connection conn = DriverManager.getConnection(
- "jdbc:oracle:thin:@192.168.69.26:31521/ORCLPDB",
- "C##DC",
- "6bcb4bd7bbhbgz9cb44")) {
- q(conn, "select RCID, JLZTM, to_char(KSSJ,'yyyy-mm-dd hh24:mi:ss') KSSJ, to_char(JSSJ,'yyyy-mm-dd hh24:mi:ss') JSSJ, MC from RC where RCID=52111738");
- q(conn, "select SQID, DXID, DXM, LBM, LCZTM, JLZTM, MC, to_char(SQSJ,'yyyy-mm-dd hh24:mi:ss') SQSJ from SQ where SQID=515051");
- q(conn, "select SQID, DXID, DXM, LBM, LCZTM, JLZTM, MC, to_char(SQSJ,'yyyy-mm-dd hh24:mi:ss') SQSJ from SQ where DXID=52111738 order by SQID desc fetch first 20 rows only");
- q(conn, "select SHID, SQID, SHLBM, SHYJM, JLZTM, SHRYID, to_char(SHSJ,'yyyy-mm-dd hh24:mi:ss') SHSJ from SH where SQID=515051 order by SHID");
- }
- }
- private static void q(Connection conn, String sql) throws Exception {
- System.out.println("===SQL=== " + sql);
- try (Statement st = conn.createStatement(); ResultSet rs = st.executeQuery(sql)) {
- ResultSetMetaData md = rs.getMetaData();
- int cols = md.getColumnCount();
- boolean has = false;
- while (rs.next()) {
- has = true;
- StringBuilder sb = new StringBuilder();
- for (int i = 1; i <= cols; i++) {
- if (i > 1) sb.append(" | ");
- sb.append(md.getColumnLabel(i)).append('=').append(rs.getString(i));
- }
- System.out.println(sb);
- }
- if (!has) System.out.println("<no rows>");
- }
- }
- }
|