maito.resource
Class ResourceLoader

java.lang.Object
  extended by maito.resource.ResourceLoader

public class ResourceLoader
extends java.lang.Object

This class acts as a buffered stream for reading Resource objects from the database.

Author:
Antti Laitinen

Constructor Summary
ResourceLoader(java.sql.Connection con)
           
 
Method Summary
 void executeSQL(java.lang.String sql)
          Executes a query in the database.
 Resource nextResource()
          Fetches the next resource produced by the latest query.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourceLoader

public ResourceLoader(java.sql.Connection con)
Method Detail

executeSQL

public void executeSQL(java.lang.String sql)
                throws java.sql.SQLException
Executes a query in the database. After this, the resources can be read using the method nextResource().

Parameters:
sql - The sql to be executed. It is executed as it is, so any validation on the query should be done outside this method.
Throws:
java.sql.SQLException - Thrown when the executed query produces an error.

nextResource

public Resource nextResource()
                      throws java.sql.SQLException
Fetches the next resource produced by the latest query.

Returns:
A Resource object representing the resource in the database. null if the query hasn't produced any resources or when all resources are read.
Throws:
java.sql.SQLException - Thrown if reading the database produces errors.