Statement s1 = null; ResultSet rs = null; stmtInfo.init(); s = stmtInfo.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, stmtInfo.getCursorType(stmtInfo.getDbname())); String count = stmtInfo.countSql(); s1 = stmtInfo.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, stmtInfo.getCursorType(stmtInfo.getDbname())); rs = s1.executeQuery(count); stmtInfo.addResultSet(rs); stmtInfo.rebuildOffset(totalSize); String paginesql = stmtInfo.paginesql(false).getSql(); if(log.isInfoEnabled() && showsql(stmtInfo.getDbname())) log.info("JDBC pageine origine statement:{}", stmtInfo.getSql()); log.info("JDBC pageine statement:{}", paginesql); stmtInfo.addResultSet(res); stmtInfo.absolute(res); stmtInfo.cacheResultSetMetaData( res,true); this.meta = stmtInfo.getMeta(); resultMap = stmtInfo.buildResultMap(res, objectType, rowhandler, stmtInfo.getMaxsize(),
stmtInfo = new StatementInfo(dbname_, new NewSQLInfo(sql_), goNative_, con_, false); stmtInfo.init(); boolean autokey = isAutoprimarykey(dbname_); s = stmtInfo.createStatement(); if(autokey) temp = StatementParser.refactorInsertStatement(stmtInfo.getCon(), stmtInfo.getSql(), stmtInfo.getDbname()); log.info("JDBC Insert statement:{}", stmtInfo.getSql()); execute(stmtInfo.getCon(), updateTableinfo); stmtInfo.commit(); int i = s.executeUpdate(stmtInfo.getSql()); stmtInfo.commit(); return new Integer(i); log.info("JDBC Insert statement:{}", stmtInfo.getSql()); int i = s.executeUpdate(stmtInfo.getSql()); stmtInfo.commit(); return new Integer(i); log.error(stmtInfo.getSql(), e);
return _prepareStatement(sql,false); this.setOffset(rebuildOffset(this.getOffset(),this.getMaxsize(),totalSize)); return this.getOffset();
public PreparedStatement preparePagineStatement(boolean showsql) throws SQLException { paginesql = new PagineSql(this.sql,true); if (this.rownum == null) { // if (this.isRobotQuery(prepareDBName)) paginesql = getDBPagineSql(true); if(log.isInfoEnabled() && showsql && paginesql != null) { log.info("Execute JDBC prepared pagine query statement:{}",paginesql.getSql()); } } else { paginesql = getDBPagineSqlForOracle(true); } return _prepareStatement(paginesql.getSql(),true); }
if(stmtInfo.getTotalsize() < 0) this.offset = stmtInfo.rebuildOffset(totalSize); if(this.offset < oldoffset)//重置数据获取范围 stmtInfo.resetPostion(statement,startidx,endidx,this.offset); this.totalSize = stmtInfo.getTotalsize(); stmtInfo.addResultSet(res); stmtInfo.absolute(res); stmtInfo.cacheResultSetMetaData( res,true); this.meta = stmtInfo.getMeta(); if(rowhandler != null) rowhandler.init(stmtInfo,meta, stmtInfo.getDbname()); resultMap = stmtInfo.buildResultMap(res, objectType, rowhandler, stmtInfo.getMaxsize(), true, result_type); stmtInfo.addResultSet(res); stmtInfo.absolute(res); stmtInfo.cacheResultSetMetaData( res,true); if(rowhandler != null) rowhandler.init(stmtInfo,meta, stmtInfo.getDbname()); this.meta = stmtInfo.getMeta(); stmtInfo.addResultSet(res); stmtInfo.absolute(res); stmtInfo.cacheResultSetMetaData( res,true); this.meta = stmtInfo.getMeta(); if(rowhandler != null)
if(pool == null) throw new NestedSQLException(new StringBuilder().append("执行sql[").append(this.Params.prepareSqlifo != null?this.Params.prepareSqlifo.getNewsql():"").append("]失败:数据源[").append(prepareDBName).append("]不存在,请检查数据源是否正确启动.").toString()); stmtInfo = new StatementInfo(this.prepareDBName, this.Params.prepareSqlifo, stmtInfo.init(); if(log.isInfoEnabled() && showsql(stmtInfo.getDbname())) statement = stmtInfo.prepareStatement(temp[0].toString()); stmtInfo.setRETURN_GENERATED_KEYS(pool.getRETURN_GENERATED_KEYS()); if(log.isInfoEnabled() && showsql(stmtInfo.getDbname())) log.info("Execute JDBC prepared statement:{}",stmtInfo.getSql()); statement = stmtInfo.prepareStatement(stmtInfo.getSql(),getCUDResult); if(log.isInfoEnabled() && showsql(stmtInfo.getDbname())) log.info("Execute JDBC prepared update statement:{}",stmtInfo.getSql()); statement = stmtInfo.prepareStatement(); boolean showsql = showsql(stmtInfo.getDbname()); stmtInfo.setPagineOrderBy(Params.getPagineOrderby()); statement = stmtInfo.preparePagineStatement(showsql); if(!this.more)
Statement s = null; if(stmtInfo != null) stmtInfo.init(); s = stmtInfo.createStatement(); if(log.isInfoEnabled() && showsql(stmtInfo.getDbname())) log.info("Execute JDBC statement:{}",stmtInfo.getSql()); boolean hasResult = s.execute(stmtInfo.getSql()); stmtInfo.addResultSet(res); stmtInfo.cacheResultSetMetaData(res,false); this.meta = stmtInfo.getMeta(); resultMap = stmtInfo.buildResultMap(res, objectType, rowhandler, 10, false, result_type); if(resultMap != null) this.size = resultMap.getSize(); results = stmtInfo.buildCommonResult(s); resultMap.setCommonresult(results); if(results != null) stmtInfo.commit(); log.error(stmtInfo.getSql(), sqle); stmtInfo.errorHandle(sqle);
try stmtInfo = new StatementInfo(this.prepareDBName, Params.prepareSqlifo, false, con_, false); stmtInfo.init(); cstmt = stmtInfo.prepareCallableStatement(); resources = new ArrayList(); super.setUpParams(stmtInfo,Params, cstmt,resources); this.setUpCallableParams(_params, cstmt); if(log.isInfoEnabled() && showsql(stmtInfo.getDbname()) ) log.info("Execute JDBC callable statement:{}",stmtInfo.getSql()); stmtInfo.addResultSet(res); stmtInfo.errorHandle(e); if(e instanceof SQLException) throw (SQLException)e; stmtInfo.dofinally(); stmtInfo = null; if(Params != null)
stmtInfo.addResultSet(res); stmtInfo.cacheResultSetMetaData( res,false); this.meta = stmtInfo.getMeta(); if(rowhandler != null) rowhandler.init(stmtInfo,meta, stmtInfo.getDbname()); ResultMap resultMap = new ResultMap(); resultMap = stmtInfo.buildResultMap(res, objectType, rowhandler, 10, false, result_type);
stmtInfo = new StatementInfo(this.prepareDBName, null, false, con_, false); stmtInfo.init(); boolean getCUDResult = CUDResult != null; if(getCUDResult) stmtInfo.setRETURN_GENERATED_KEYS(pool.getRETURN_GENERATED_KEYS()); boolean showsql = showsql(stmtInfo.getDbname()); int i = 0; while(i < batchparams.size() ) .prepareStatement(Params.prepareSqlifo.getNewsql(),getCUDResult); if(resources == null) resources = new ArrayList(); .prepareStatement(Params.prepareSqlifo.getNewsql(),getCUDResult); if(resources == null) resources = new ArrayList(); List<Object> morekeys = StatementInfo.getGeneratedKeys(statement); stmtInfo.errorHandle(error); stmtInfo.errorHandle(e); if(e instanceof SQLException)
xhdl.init(this,this.getMeta(), this.getDbname()); rowHandler = xhdl; isxmlhandler = true; xhdl.init(this,this.getMeta(), this.getDbname()); this.cacheResultSetMetaData(res,ispagine); boolean go = true; if (ispagine) go = res.next() && rowcount < getMaxsize(); else go = res.next(); rowcount++; if (ispagine) go = res.next() && rowcount < getMaxsize(); else go = res.next();
stmtInfo = new StatementInfo(dbname, null, false, con_, false); stmtInfo.init(); .prepareStatement(sql.getSql()); if(batchsize <= 1 ){//如果batchsize被设置为0或者1直接一次性批处理所有记录 for(int i = 0;i < datas.size(); i ++ ) stmtInfo.errorHandle(error); stmtInfo.errorHandle(e); if(e instanceof SQLException) throw (SQLException)e; } finally { if(stmtInfo != null) stmtInfo.dofinally(); stmtInfo = null;
&& Map.class.isAssignableFrom(objectType))) Record[] results = buildResult(res,containersize,ispagine); resultMap.setCommonresult(results); if(results != null) List<T> results = buildResultForList(res, containersize, ispagine, objectType, rowhandler); resultMap.setCommonresult(results); if(results != null) Object[] results = buildResultForObjectArray(res, containersize, ispagine, objectType, rowhandler); resultMap.setCommonresult(results); if(results != null) resultMap.setCommonresult(buildResultForXml(res, containersize, ispagine, objectType, rowhandler)); resultMap.setSize(getRowcount()); this.rowcount = buildResult(res, ispagine, rowhandler); resultMap.setSize(getRowcount());
throw new NestedSQLException(e1); Record data = buildMap(rs, stmtInfo,stmtInfo.getDbadapter()); try PoolManResultSetMetaData meta = stmtInfo.getMeta(); for (int n = 0; attributes != null && n < attributes.size(); n++) { PropertieDescription attribute = attributes.get(n); stmtInfo.getMeta().getColumnTypeByIndex(i), type, stmtInfo.getDbadapter(),editor,cl); stmtInfo.getSql()).append("] Get Column[") .append(columnName).append("] from ResultSet to ").append(valueObjectType.getClass().getCanonicalName()).append(".") .append(attrName).append("[") StringBuilder err = new StringBuilder( "Build ValueObject for ResultSet[").append( stmtInfo.getSql()).append("] Get Column[") .append(columnName).append("] from ResultSet to ").append(valueObject).append(".") .append(attrName).append("[") stmtInfo.getMeta().getColumnTypeByIndex(0), valueObjectType, stmtInfo.getDbadapter(),(ColumnEditorInf)null,(ColumnWraper)null);
public void executeSelectWithRowhandler(String dbname, String sql, Connection con,NullRowHandler rowhandler) throws SQLException { StatementInfo stmtInfo = null; try { stmtInfo = new StatementInfo(dbname, new NewSQLInfo(sql), false,con,false); ResultMap resultMap = innerExecuteJDBC(stmtInfo, null,rowhandler,ResultMap.type_null); // return (List)resultMap.getCommonresult(); } finally { if(stmtInfo != null) { stmtInfo.dofinally(); stmtInfo = null; } } }
@Override public void handleResult(ResultSet resultSet, StatementInfo statementInfo) throws Exception { esjdbc.setResultSet(resultSet); esjdbc.setMetaData(statementInfo.getMeta()); JDBCRestClientUtil jdbcRestClientUtil = new JDBCRestClientUtil(); jdbcRestClientUtil.addDocuments(esjdbc.buildIndexName(), esjdbc.getIndexType(), esjdbc, esjdbc.getRefreshOption(), batchSize); } }
public static <T> T buildMap(Class<T> valueObjectType,ResultSet rs,StatementInfo stmtInfo) throws SQLException { Map valueObject = null; PoolManResultSetMetaData meta = stmtInfo.getMeta(); .getColumnType(i), stmtInfo.getDbadapter()); if(stmtInfo.getDbadapter().columnLableUpperCase()) { valueObject.put(meta .getColumnLabelUpper(i),
public void executeSelectWithRowhandler(String dbname, String sql,long offset,int pagesize, Connection con,NullRowHandler rowhandler) throws SQLException { StatementInfo stmtInfo = new StatementInfo(dbname, new NewSQLInfo(sql), false, offset, pagesize, true, con,oraclerownum); this.innerExecutePagineJDBC(stmtInfo, null, rowhandler, ResultMap.type_null); }
public PreparedStatement prepareStatement() throws SQLException { // PreparedStatement pstmt = this.con.prepareStatement(this.sql,this.getScrollType(dbname),this.getCursorType(dbname)); // this.statements.add(pstmt); // return pstmt; return _prepareStatement(false); }
public List executeSelectForList(String dbname, String sql, Connection con,Class objectType,RowHandler rowhandler) throws SQLException { StatementInfo stmtInfo = null; try { stmtInfo = new StatementInfo(dbname, new NewSQLInfo(sql), false,con,false); ResultMap resultMap = innerExecuteJDBC(stmtInfo, objectType,rowhandler,ResultMap.type_list); return (List)resultMap.getCommonresult(); } finally { if(stmtInfo != null) { stmtInfo.dofinally(); stmtInfo = null; } } }