package org.tonjac.mini.test; import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.Properties; import org.tonjac.mini.*; /* mini * * This program is distributed under the GNU General Public License, version 2. * A copy of this license is included with this source. * * Copyright 2004-2006, Toni Thomsson */ public class TestTableData implements DataService { public TestTableData( ) { } public DataServiceReply execute( Session session, Properties args ) throws Exception { DataServiceReply reply = new DataServiceReply(); ResultSet rs = null; Statement sql = null; try { Connection conn = session.getConnection(); reply.addFieldName( "row" ); sql = conn.createStatement( ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY ); rs = sql.executeQuery( "select name from test" ); while( rs.next() ) reply.addFieldValue( rs.getString("name") ); } catch( SQLException e ) { throw e; } finally { if( rs != null ) rs.close(); if( sql != null ) sql.close(); } return reply; } }