Codota Logo
ClasspathStatementLocator
Code IndexAdd Codota to your IDE (free)

How to use
ClasspathStatementLocator
in
org.skife.jdbi.v2

Best Java code snippets using org.skife.jdbi.v2.ClasspathStatementLocator (Showing top 14 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Connection c =
  • Codota IconDataSource dataSource;dataSource.getConnection()
  • Codota IconString url;DriverManager.getConnection(url)
  • Codota IconIdentityDatabaseUtil.getDBConnection()
  • Smart code suggestions by Codota
}
origin: com.ning.jdbi/jdbi-metrics

  @Override
  public StatementName getStatementName(final StatementContext statementContext)
  {
    final String rawSql = statementContext.getRawSql();
    if (ClasspathStatementLocator.looksLikeSql(rawSql)) {
      return forRawSql(rawSql);
    }
    return null;
  }
}
origin: org.jdbi/jdbi

protected StatementLocator getStatementLocator()
{
  return new ClasspathStatementLocator();
}
origin: com.ning.billing/killbill-osgi-bundles-analytics

/**
 * Very basic sanity test to see if a string looks like it might be sql
 */
public static boolean looksLikeSql(String sql)
{
  final String local = left(stripStart(sql), 7).toLowerCase();
  return local.startsWith("insert ")
      || local.startsWith("update ")
      || local.startsWith("select ")
      || local.startsWith("call ")
      || local.startsWith("delete ")
      || local.startsWith("create ")
      || local.startsWith("alter ")
      || local.startsWith("drop ");
}
origin: org.kill-bill.commons/killbill-jdbi

  cache_key = '/' + mungify(ctx.getSqlObjectType().getName() + '.' + name) + ".sql";
if (looksLikeSql(name)) {
final ClassLoader loader = selectClassLoader();
BufferedReader reader = null;
try {
    String filename = '/' + mungify(ctx.getSqlObjectType().getName() + '.' + name) + ".sql";
    in_stream = loader.getResourceAsStream(filename);
    if (in_stream == null) {
  try {
    while ((line = reader.readLine()) != null) {
      if (isComment(line)) {
origin: com.ning.billing/killbill-osgi-bundles-analytics

  cache_key = '/' + mungify(ctx.getSqlObjectType().getName() + '.' + name) + ".sql";
if (looksLikeSql(name)) {
  found.putIfAbsent(cache_key, name);
  return name;
final ClassLoader loader = selectClassLoader();
BufferedReader reader = null;
try {
    String filename = '/' + mungify(ctx.getSqlObjectType().getName() + '.' + name) + ".sql";
    in_stream = loader.getResourceAsStream(filename);
    if (in_stream == null) {
  try {
    while ((line = reader.readLine()) != null) {
      if (isComment(line)) {
origin: com.yammer.metrics/metrics-jdbi

  @Override
  public MetricName getStatementName(StatementContext statementContext) {
    final String rawSql = statementContext.getRawSql();
    if (ClasspathStatementLocator.looksLikeSql(rawSql)) {
      return forRawSql(rawSql);
    }
    return null;
  }
}
origin: org.kill-bill.commons/killbill-jdbi

/**
 * Very basic sanity test to see if a string looks like it might be sql
 */
public static boolean looksLikeSql(String sql)
{
  final String local = left(stripStart(sql), 8).toLowerCase();
  return local.startsWith("insert ")
      || local.startsWith("update ")
      || local.startsWith("select ")
      || local.startsWith("call ")
      || local.startsWith("delete ")
      || local.startsWith("create ")
      || local.startsWith("alter ")
      || local.startsWith("merge ")
      || local.startsWith("replace ")
      || local.startsWith("drop ");
}
origin: org.kill-bill.commons/killbill-jdbi

protected StatementLocator getStatementLocator()
{
  return new ClasspathStatementLocator();
}
origin: io.kazuki/kazuki-db

 public String locate(String name, StatementContext ctx) throws Exception {
  if (ClasspathStatementLocator.looksLikeSql(name)) {
   return name;
  }
  final StringTokenizer tok = new StringTokenizer(name, ":");
  final String group_name = tok.nextToken();
  final String template_name = tok.nextToken();
  final StringTemplateGroup group = loader.loadGroup(group_name);
  final StringTemplate template = group.getInstanceOf(template_name);
  template.setAttributes(ctx.getAttributes());
  return template.toString();
 }
});
origin: org.kill-bill.commons/killbill-jdbi

  @Test
  public void testCachesOriginalQueryWhenNotFound() throws Exception
  {
    StatementLocator statementLocator = new ClasspathStatementLocator();
    StatementContext statementContext = new TestingStatementContext(new HashMap<String, Object>()) {

      @Override
      public Class<?> getSqlObjectType() {
        return TestClasspathStatementLocator.class;
      }
    };

    String input = "missing query";
    String located = statementLocator.locate(input, statementContext);

    assertEquals(input, located); // first time just caches it

    located = statementLocator.locate(input, statementContext);

    assertEquals(input, located); // second time reads from cache
  }
}
origin: org.jdbi/jdbi

@Test
public void testCachesOriginalQueryWhenNotFound() throws Exception
{
  StatementLocator statementLocator = new ClasspathStatementLocator();
  StatementContext statementContext = new TestingStatementContext(new HashMap<String, Object>()) {
    @Override
    public Class<?> getSqlObjectType() {
      return TestClasspathStatementLocator.class;
    }
    @Override
    public Method getSqlObjectMethod() {
      return null;
    }
  };
  String input = "missing query";
  String located = statementLocator.locate(input, statementContext);
  assertEquals(input, located); // first time just caches it
  located = statementLocator.locate(input, statementContext);
  assertEquals(input, located); // second time reads from cache
}
origin: org.jdbi/jdbi

@Test
public void testCachesOriginalQueryByMethodWhenNotFound() throws Exception
{
  StatementLocator statementLocator = new ClasspathStatementLocator();
  StatementContext statementContext = new TestingStatementContext(new HashMap<String, Object>()) {
    @Override
    public Class<?> getSqlObjectType() {
      return TestClasspathStatementLocator.class;
    }
    @Override
    public Method getSqlObjectMethod() {
      try {
        return TestClasspathStatementLocator.class.getMethod("testCachesOriginalQueryByMethodWhenNotFound");
      } catch (NoSuchMethodException e) {
        throw new RuntimeException(e);
      }
    }
  };
  String input = "missing query";
  String located = statementLocator.locate(input, statementContext);
  assertEquals(input, located); // first time just caches it
  located = statementLocator.locate(input, statementContext);
  assertEquals(input, located); // second time reads from cache
}
origin: org.kill-bill.commons/killbill-jdbi

new ClasspathStatementLocator(),
builder,
new ColonPrefixNamedParamStatementRewriter(),
origin: org.jdbi/jdbi

new ClasspathStatementLocator(),
builder,
new ColonPrefixNamedParamStatementRewriter(),
org.skife.jdbi.v2ClasspathStatementLocator

Javadoc

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

Most used methods

  • looksLikeSql
    Very basic sanity test to see if a string looks like it might be sql
  • <init>
  • isComment
  • left
  • mungify
  • selectClassLoader
    There *must* be a better place to put this without creating a helpers class just for it
  • stripStart

Popular in Java

  • Parsing JSON documents to java classes using gson
  • addToBackStack (FragmentTransaction)
  • runOnUiThread (Activity)
  • onRequestPermissionsResult (Fragment)
  • Menu (java.awt)
  • FileReader (java.io)
    A specialized Reader that reads from a file in the file system. All read requests made by calling me
  • Permission (java.security)
    Abstract class for representing access to a system resource. All permissions have a name (whose inte
  • SortedSet (java.util)
    A Set that further provides a total ordering on its elements. The elements are ordered using their C
  • ThreadPoolExecutor (java.util.concurrent)
    An ExecutorService that executes each submitted task using one of possibly several pooled threads, n
  • Reference (javax.naming)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now