congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
ClasspathStatementLocator
Code IndexAdd Tabnine 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)

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

  • Making http requests using okhttp
  • getSharedPreferences (Context)
  • requestLocationUpdates (LocationManager)
  • putExtra (Intent)
  • RandomAccessFile (java.io)
    Allows reading from and writing to a file in a random-access manner. This is different from the uni-
  • Hashtable (java.util)
    A plug-in replacement for JDK1.5 java.util.Hashtable. This version is based on org.cliffc.high_scale
  • Executor (java.util.concurrent)
    An object that executes submitted Runnable tasks. This interface provides a way of decoupling task s
  • HttpServletRequest (javax.servlet.http)
    Extends the javax.servlet.ServletRequest interface to provide request information for HTTP servlets.
  • JButton (javax.swing)
  • Base64 (org.apache.commons.codec.binary)
    Provides Base64 encoding and decoding as defined by RFC 2045.This class implements section 6.8. Base
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now