JFinal 分頁查詢 Connection conn=config.getConnection(); conn爲null是怎麼回事

/**
     * Paginate.
     * @param pageNumber the page number
     * @param pageSize the page size
     * @param select the select part of the sql statement 
     * @param sqlExceptSelect the sql statement excluded select part
     * @param paras the parameters of sql
     * @return Page
     */
    publicPage<M> paginate(intpageNumber,intpageSize, String select, String sqlExceptSelect, Object... paras) {
        Config config = getConfig();


        Connection conn = null;
        try{
            conn = config.getConnection();
            returnpaginate(config, conn, pageNumber, pageSize, select, sqlExceptSelect, paras);
        }catch(Exception e) {
            thrownewActiveRecordException(e);
        }finally{
            config.close(conn);
        }
    }


原因:model沒綁定的時候 貌似會抱一個類似的錯;.
解決方法:在BaseConfig中的插件配置configPlugin中進行DB映射(例如:arp.addMapping(tableName,primary Key,modelClass.class))。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章