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!
JDBI is scanning your interface's annotations. Use the
@SqlQuery
annotation.