NoSuchMethodError JDBI

907 views Asked by At

I am trying to create a table something in my class using such method:

void createTab() {
DBI dbi = new DBI(DBURL, DBUSER, DBPASS);

BindExamples dao = dbi.open(BindExamples.class);

dao.createSomethingTable();
    dao.close();
}

My BindExamples interface:

public interface BindExamples

{
@SqlUpdate("insert into something (id, name) values (:id, :name)")
void insert(@Bind("id") int id, @Bind("name") String name);

@SqlUpdate("delete from something where name = :it")
void deleteByName(@Bind("name") String name);

@SqlSelect("select text from articles where id = :id")
String selectText(@Bind("id") int id);

@SqlUpdate("create table something (id int primary key, name varchar(100))")
  void createSomethingTable();

void close();
}

Result: I've got an error:

Exception in thread "main" java.lang.NoSuchMethodError:java.lang.Object.createSomethingTable()V
at org.skife.jdbi.v2.sqlobject.CloseInternalDoNotUseThisClass$$EnhancerByCGLIB$$7c60a575.CGLIB$createSomethingTable$8(<generated>)
at org.skife.jdbi.v2.sqlobject.CloseInternalDoNotUseThisClass$$EnhancerByCGLIB$$7c60a575$$FastClassByCGLIB$$c61ecaca.invoke(<generated>)
at org.skife.jdbi.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
    at org.skife.jdbi.v2.sqlobject.PassThroughHandler.invoke(PassThroughHandler.java:21)
    at org.skife.jdbi.v2.sqlobject.SqlObject.invoke(SqlObject.java:147)
    at org.skife.jdbi.v2.sqlobject.SqlObject$1.intercept(SqlObject.java:60)
    at org.skife.jdbi.v2.sqlobject.CloseInternalDoNotUseThisClass$$EnhancerByCGLIB$$7c60a575.createSomethingTable(<generated>)
    at DBAccessJDBC.saveObjectAPI(DBAccessJDBC.java:58)
    at MainMain.main(MainMain.java:7)

Any ideas what did i wrong? I am trying to to the same as in http://jdbi.codehaus.org/five_minute_intro/

I use:

  • 2.48.2 version of JDBI library
  • eclipse
  • mySql

Thanks for any help!

2

There are 2 answers

0
Bilal and Olga On

JDBI is scanning your interface's annotations. Use the @SqlQuery annotation.

0
Manikandan On

There is no annotation @SqlSelect in jdbi. Can you say, from which library you are using this annotation. I changed the annotation to @SqlQuery, it works fine. It will scan all the methods and based on the annotation it'll allocate handlers. Scanning might have failed because of the unknown annotation.