Populate data from SQL model to listbox

Hi,I'm looking for a example or sample codes that create a sql modeland populate the data into a listbox. Thanks!Regards,Joe
[188 byte] By [Guest] at [2007-11-25 9:35:56]
# 1
sorry for the very late response...Here is a tip on the JATO-Tips forum that should give you some insights. http://groups.yahoo.com/group/iPlanet-JATO-Tips/message/22If you still have questions, let us know.
cvconover at 2007-7-1 18:37:51 > top of Java-index,Development Tools,Java Tools...
# 2

I am trying to populate a select box from a sql model. I refered to the tip on the JATO-tips forum.

I get a reference to the model and execute the correct query. But when I try to loop through the ResultSet I get a SQLException: Closed Connection: next.

Please let me know if you ran into any similar issues. Any help is appreciated. - Thanks

Here is a sample of the code from my ViewBean (All of the commented out variations give me that same exception)

protected void populateOptionListJobStatus()

{

LookupModel model = (LookupModel)getModel(LookupModel.class);

model.clearUserWhereCriteria();

model.addUserWhereCriterion("ZLOOKUP_LOOKUP_TYPE", "Job_Status");

SimpleChoice choice;

try

{

DatasetModelExecutionContext context = this.createDefaultExecutionContext();

//ResultSet rs = model.executeSelect(this.getAutoRetrieveExecutionContext());

ResultSet rs = model.executeSelect(context);

//ResultSet rs = model.getResultSet();

//ResultSet rs = model.executeSelect(this.getLastActionExecutionContext());

System.out.println("NUMBER OF ROWS: " + model.getNumRows());

choiceArray = new Choice[model.getNumRows()];

int index = 0;

if(rs != null && model.getNumRows() > 0)

{

while(rs.next())

{

Sara Seissiger at 2007-7-1 18:37:51 > top of Java-index,Development Tools,Java Tools...
# 3
Sara,Instead of using the Resultset, you can just use the Model.pseudocode:model.executeSelectmodel.beforeFirstwhile (model.next) model.getValueIf you need more specific code or have questions, let us knowcraig
cvconover at 2007-7-1 18:37:51 > top of Java-index,Development Tools,Java Tools...