org.benow.web.complete
Class JDBCCompleter

java.lang.Object
  extended by org.benow.web.complete.Completer
      extended by org.benow.web.complete.JDBCCompleter
All Implemented Interfaces:
java.lang.Iterable<CompleteResult>, java.util.Iterator<CompleteResult>
Direct Known Subclasses:
JSQLFieldCompleter

public abstract class JDBCCompleter
extends Completer


Nested Class Summary
 
Nested classes/interfaces inherited from class org.benow.web.complete.Completer
Completer.Completes
 
Field Summary
 
Fields inherited from class org.benow.web.complete.Completer
cancelled, parameters, prefix
 
Constructor Summary
protected JDBCCompleter(java.lang.String prefix, java.lang.String params)
           
 
Method Summary
protected  void bind(java.sql.PreparedStatement stmt)
          Binds parameters to the statement, if required
protected  java.sql.Connection createConnection()
           
protected abstract  CompleteResult createResult(java.sql.ResultSet rs)
          Create the result from the current row in the result set
protected  void doClose()
           
protected  boolean doHasNext()
           
protected  CompleteResult doNext()
           
protected abstract  java.lang.String getSQL()
           
protected  void init()
          Do something before any results are generated
 
Methods inherited from class org.benow.web.complete.Completer
cancel, close, getCompletionsFor, getCompletionsFor, getCompletionsFor, getForClass, getForField, hasFailed, hasNext, isSufficient, iterator, next, remove, setHasFailed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JDBCCompleter

protected JDBCCompleter(java.lang.String prefix,
                        java.lang.String params)
                 throws java.sql.SQLException
Throws:
java.sql.SQLException
Method Detail

init

protected void init()
             throws java.lang.Exception
Description copied from class: Completer
Do something before any results are generated

Overrides:
init in class Completer
Throws:
java.lang.Exception

bind

protected void bind(java.sql.PreparedStatement stmt)
             throws java.sql.SQLException
Binds parameters to the statement, if required

Parameters:
stmt -
Throws:
java.sql.SQLException

getSQL

protected abstract java.lang.String getSQL()
Returns:
sql for query

createConnection

protected java.sql.Connection createConnection()
                                        throws java.lang.Exception
Returns:
a new connection, defaults to JDBCRepository.getConnection()
Throws:
java.sql.SQLException
java.lang.Exception

doHasNext

protected boolean doHasNext()
Specified by:
doHasNext in class Completer

doNext

protected CompleteResult doNext()
Specified by:
doNext in class Completer

createResult

protected abstract CompleteResult createResult(java.sql.ResultSet rs)
                                        throws java.sql.SQLException
Create the result from the current row in the result set

Parameters:
rs -
Returns:
created result
Throws:
java.sql.SQLException

doClose

protected void doClose()
Overrides:
doClose in class Completer