Popular Posts
vi hot key guide 第一部份:一般模式可用的按鈕說明,游標移動、複製貼上、搜尋取代等 移動游標的方法 h 或 向左方向鍵(←) 游標向左移動一個字元 j 或 向下方向鍵(↓) 游標向下移動一個字元 k 或 向上方向鍵(↑) 游標向上移動一個字元 l 或 向右方向鍵(→) 游標... Asynchronous and deferred JavaScript execution explained Normal execution <script> This is the default behavior of the <script> element. Parsing of the HTML code pauses while the scr... Enable SSL connection for Jsoup import org.jsoup.Connection; import org.jsoup.Jsoup; import javax.net.ssl.*; import java.io.IOException; import java.security.KeyManagement...
Stats
SqlCommand (Sample)
new SqlCommand() //
.setDebugMode(true)
.setConnection(Connector.get())
.setCommandText("SELECT" +
        "    e.entry_id," +
        "    e.entry_name," +
        "    e.entry_english_name," +
        "    e.entry_description," +
        "    e.entry_sop_path," +
        "    e.entry_cordon," +
        "    e.role_name," +
        "    e.entry_enabled," +
        "    e.group_id," +
        "    e.group_name" +
        " FROM mv_wrk e" +
        " WHERE" +
        "    (&entry_id IS NULL OR UPPER(e.entry_id) LIKE UPPER(&entry_id))" +
        "    AND (&entry_name IS NULL OR UPPER(e.entry_name) LIKE UPPER(&entry_name))" +
        "    AND (&entry_english_name IS NULL OR UPPER(e.entry_english_name) LIKE UPPER(&entry_english_name))" +
        "    AND (&entry_enabled IS NULL OR e.entry_enabled = &entry_enabled)" +
        " ORDER BY e.entry_id ASC")
.addParameter("&entry_id", OracleDataType.VARCHAR2)
.addParameter("&entry_name", OracleDataType.VARCHAR2, null)
.addParameter(new SqlParameter("&entry_english_name", OracleDataType.VARCHAR2))
.addParameter(new SqlParameter("&entry_enabled", OracleDataType.NUMBER).setValue(null))
.setAdapter(new QueryAdapter() {
    @Override
    public void executedQuery(SqlArgument arg) throws Exception {
        ResultSet rs;
        if ((rs = ((QueryArgument) arg).resultset) == null)
            return;

        while (rs.next()) {
            System.err.println(DataMap.fill(rs));
        }
    }
})
.query();
batch
new SqlCommand()
.setDebugMode(true)
.setDebugOut(System.err)
.setConnection(ConnectionUtil.get())
.addCommand("/* 1. &name 2. &aid  3. &time */ INSERT INTO access_log VALUES(&aid, &name, &time)", CommandType.Text, CommandMode.Batch)
.addCommand("SELECT * FROM access_log WHERE rownum < &rows ORDER BY time DESC")
.addParameter("&rows", OracleDataType.INT, 5)
.setAdapter(new QueryListener() {
    @Override
    public boolean executingQuery(SqlArgument arg) throws Exception {
        if (arg.first && arg.mode == CommandMode.Batch)
            for (int i = 0; i < 3; i++) {
                arg.addBatchParameters(
                    new SqlParameter("&name", OracleDataType.VARCHAR2, "bruce"),
                    new SqlParameter("&aid", OracleDataType.VARCHAR2, UUID.randomUUID().toString()),
                    new SqlParameter("&time", OracleDataType.DATE, DateTime.now().toTimestamp())
                );
            }

        return true;
    }

    @Override
    public void executedQuery(SqlArgument arg) throws Exception {
        if (arg.first) {
            UpdateArgument ua = (UpdateArgument) arg;
            System.err.println(Arrays.toString(ua.batchResult));
        } else {
            QueryArgument argument = (QueryArgument) arg;
            if (argument.resultset != null)
                while (argument.resultset.next()) {
                    System.err.println(DataMap.fill(argument.resultset));
                }
        }
    }
})
.query();