Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save akovac35/1d286ca51a399c5bb15ca02e7f2eadad to your computer and use it in GitHub Desktop.
Save akovac35/1d286ca51a399c5bb15ca02e7f2eadad to your computer and use it in GitHub Desktop.
SelectCatentriesWithoutUrlCmdImpl.java
package com.ak.commerce.database;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.ibm.commerce.exception.ECException;
import com.ibm.commerce.exception.ECSystemException;
import com.ibm.commerce.exception.ParameterNotFoundException;
import com.ibm.commerce.foundation.common.util.logging.LoggingHelper;
import com.ibm.commerce.foundation.internal.common.exception.FoundationSystemException;
import com.ibm.commerce.ras.ECMessage;
/**
*
* @author Aleksander Kovac, IBM
*
*/
public class SelectCatentriesWithoutUrlCmdImpl extends DbAccessCmdImpl<List<Long>> implements SelectCatentriesWithoutUrlCmd {
/**
* The name of this implementation of the command.
*/
public final static String CLASSNAME = SelectCatentriesWithoutUrlCmdImpl.class.getName();
/**
* The class logger.
*/
public final static Logger LOGGER = LoggingHelper.getLogger(SelectCatentriesWithoutUrlCmdImpl.class);
public final static String SelectCatentriesWithoutUrl = "SelectCatentriesWithoutUrl";
private long _memberId;
public long getMemberId() {
return _memberId;
}
public void setMemberId(long memberId) {
this._memberId = memberId;
}
public SelectCatentriesWithoutUrlCmdImpl() {
super();
String sql = DbUtils.getSQL(SelectCatentriesWithoutUrl);
this.setSql(sql);
}
@Override
public void parseSqlResult(ResultSet rs) throws SQLException, Exception {
final String METHODNAME = "parseSqlResult(ResultSet rs)";
this._result = new ArrayList<Long> ();
while(rs.next()) {
this._result.add(rs.getLong("CATENTRY_ID"));
}
LOGGER.logp(Level.FINE, CLASSNAME, METHODNAME,"result: {0}", new Object[] {this._result});
}
@Override
public void setSqlParameters(PreparedStatement stmt) throws SQLException,
Exception {
stmt.setLong(1, this._memberId);
}
@Override
public void reset() {
super.reset();
this._memberId = 0;
}
@Override
public void validateParameters() throws ECException {
final String METHODNAME = "validateParameters()";
if (LoggingHelper.isEntryExitTraceEnabled(LOGGER)) {
LOGGER.entering(CLASSNAME, METHODNAME);
}
LOGGER.logp(Level.FINER, CLASSNAME, METHODNAME,"sql: {0}, memberId: {1}", new Object[] {this._sql, this._memberId});
super.validateParameters();
if(this._sql == null || this._sql == "")
{
throw new ParameterNotFoundException("sql");
}
if (LoggingHelper.isEntryExitTraceEnabled(LOGGER)) {
LOGGER.exiting(CLASSNAME, METHODNAME);
}
}
@Override
public void performExecute() throws ECException {
final String METHODNAME = "performExecute()";
if (LoggingHelper.isEntryExitTraceEnabled(LOGGER)) {
LOGGER.entering(CLASSNAME, METHODNAME);
}
super.performExecute();
try {
DbUtils.executeQuery(this._sql, this);
} catch (FoundationSystemException e) {
throw new ECSystemException(ECMessage._ERR_GENERIC, CLASSNAME, METHODNAME, new Object[]{e.getMessage()}, e);
} catch (SQLException e) {
throw new ECSystemException(ECMessage._ERR_SQL_EXCEPTION, CLASSNAME, METHODNAME, new Object[]{e.getMessage()}, e);
} catch (Exception e) {
throw new ECSystemException(ECMessage._ERR_GENERIC, CLASSNAME, METHODNAME, new Object[]{e.getMessage()}, e);
}
if (LoggingHelper.isEntryExitTraceEnabled(LOGGER)) {
LOGGER.exiting(CLASSNAME, METHODNAME);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment