1 16 17 package org.apache.cocoon.components.language.markup.xsp; 18 19 import org.apache.cocoon.components.language.markup.xsp.AbstractEsqlQuery; 20 21 import java.sql.SQLException ; 22 import java.sql.ResultSet ; 23 import java.sql.Connection ; 24 25 29 final public class MysqlEsqlQuery extends AbstractEsqlQuery { 30 31 public MysqlEsqlQuery(Connection connection, String query) { 32 super(connection, query); 33 } 34 35 39 private MysqlEsqlQuery(final ResultSet resultSet) { 40 super(resultSet); 41 } 42 43 47 public AbstractEsqlQuery newInstance(ResultSet resultSet) { 48 return( new MysqlEsqlQuery(resultSet) ); 49 } 50 51 public String getQueryString() throws SQLException { 52 if (getSkipRows() > 0) { 53 if (getMaxRows() > -1) { 54 return (new StringBuffer (super.getQueryString()) 55 .append(" LIMIT ").append(getSkipRows()) 56 .append(",").append(getMaxRows()+1) 57 .toString()); 58 } 59 else { 60 throw new SQLException ("MySQL does not support a skip of rows only. Please also provide the max amount of rows"); 61 } 62 } 63 else { 64 if (getMaxRows() > -1) { 65 return (new StringBuffer (super.getQueryString()) 66 .append(" LIMIT ").append(getMaxRows()+1) 67 .toString()); 68 } 69 else { 70 return (super.getQueryString()); 71 } 72 } 73 } 74 75 public void getResultRows() throws SQLException { 76 setPosition(getSkipRows()); 77 } 78 } 79 | Popular Tags |