org.skife.jdbi.v2
Class ClasspathStatementLocator

java.lang.Object
  extended by org.skife.jdbi.v2.ClasspathStatementLocator
All Implemented Interfaces:
StatementLocator

public class ClasspathStatementLocator
extends Object
implements StatementLocator

looks for [name], then [name].sql on the classpath


Constructor Summary
ClasspathStatementLocator()
           
 
Method Summary
 String locate(String name, StatementContext ctx)
          If the passed in name doesn't look like SQL it will search the classpath for a file which looks like the provided name.
static boolean looksLikeSql(String sql)
          Very basic sanity test to see if a string looks like it might be sql
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClasspathStatementLocator

public ClasspathStatementLocator()
Method Detail

locate

public String locate(String name,
                     StatementContext ctx)
If the passed in name doesn't look like SQL it will search the classpath for a file which looks like the provided name.

The "looks like" algorithm is not very sophisticated, it basically looks for the string to begin with insert, update, select, call, delete, create, alter, or drop followed by a space.

If no resource is found using the passed in string, the string s returned as-is

Specified by:
locate in interface StatementLocator
Parameters:
name - Name or statement literal
Returns:
SQL to execute (which will go to a StatementRRewrter first)
Throws:
UnableToCreateStatementException - if an IOException occurs reading a found resource

looksLikeSql

public static boolean looksLikeSql(String sql)
Very basic sanity test to see if a string looks like it might be sql



Copyright © 2011. All Rights Reserved.