View Javadoc
1 package net.sf.voruta; 2 3 import java.sql.*; 4 /*** 5 * retrieves single value from result set 6 * @author baliuka 7 */ 8 public class ScalarHandler implements ResultSetHandler { 9 10 /*** Creates a new instance of ScalarHandler */ 11 public ScalarHandler() { 12 } 13 14 public Object handle(DbResultSet rs,Class type, Object[] params) 15 throws Exception{ 16 17 if (rs.next()) { 18 Object result = rs.get(0); 19 if(rs.next()){ 20 throw new DbException("too many results"); 21 } 22 return result; 23 } 24 throw new DbException("no results"); 25 } 26 27 28 }

This page was automatically generated by Maven