View Javadoc
1 /*** $Id: JdbcOracleNTopQueryWrapperAction.java,v 1.1.1.1 2004/05/18 10:50:18 mochoa Exp $ */ 2 package org.j2ee.dao.util; 3 4 import org.j2ee.dao.JdbcDAOAction; 5 import org.j2ee.dao.AbstractJdbcDAOAction; 6 import java.sql.ResultSet; 7 import java.sql.SQLException; 8 import java.sql.PreparedStatement; 9 10 /*** 11 * Action Wrapper that implements the N-Top Query 12 * 13 * Last modified $Date: 2004/05/18 10:50:18 $ 14 * @version $Revision: 1.1.1.1 $ 15 * @author jvlio (jvlio@users.sourceforge.net)*/ 16 public class JdbcOracleNTopQueryWrapperAction extends AbstractJdbcDAOAction { 17 private long firstRow = 1; 18 private int numberOfRows = 20; 19 private JdbcDAOAction action = null; 20 21 public JdbcOracleNTopQueryWrapperAction() { super(JdbcDAOAction.QUERY); } 22 public JdbcOracleNTopQueryWrapperAction(JdbcDAOAction action) { this(); setAction(action); } 23 24 public int getNumberOfRows() { return numberOfRows; } 25 public void setNumberOfRows(int numberOfRows) { this.numberOfRows = numberOfRows; } 26 27 public long getFirstRow() { return firstRow; } 28 public void setFirstRow(long firstRow) { this.firstRow = firstRow; } 29 30 public JdbcDAOAction getAction() { return action; } 31 public void setAction(JdbcDAOAction action) { 32 // @todo: if (!action.isQuery()) throw new Exception(); 33 this.action = action; 34 } 35 36 public String getSQL() { 37 System.out.println("NTopQueryWrapperAction.getSQL: from="+firstRow+" to="+(firstRow+numberOfRows)); 38 String query = action.getSQL(); 39 String ntopquery = "SELECT * FROM (SELECT ROWNUM AS _ntop_rn_ntop_,q.* FROM ("+query+") q ) WHERE (_ntop_rn_ntop_>="+firstRow+") AND (_ntop_rn_ntop_<"+(firstRow+numberOfRows)+")"; 40 return ntopquery; 41 } 42 43 public Object[] getParameters() { return action.getParameters(); } 44 public int[] getDataTypesForParams() { return action.getDataTypesForParams(); } 45 public void handleResults(ResultSet rs) throws SQLException { action.handleResults(rs); } 46 47 public void cachPreparedStatement(PreparedStatement pstmt) { action.cachPreparedStatement(pstmt); } 48 public PreparedStatement getPreparedStatement() { return action.getPreparedStatement(); } 49 50 public boolean isCaching() { return action.isCaching(); } 51 public void setCaching(boolean caching) { action.setCaching(caching); } 52 53 }

This page was automatically generated by Maven