mysql - Binding table names to SQL query using JDBI -


i issuing simple mysql select query using jdbi. in if try bind table name, getting wrong sql syntax error.

code snippet:

@sqlquery("select * <table> rowid=:rowid") @singlevalueresult @mapper(contentrecordmapper.class) public abstract optional<document> getrecord(@define("table") string table, @bind("rowid") string rowid); 

if execute this, getting

com.mysql.jdbc.exceptions.jdbc4.mysqlsyntaxerrorexception: have error in sql syntax; check manual corresponds mysql server version right syntax use near '<table> rowid='row1'' @ line 1 [statement:"select * <table> rowid=:rowid", located:"select * <table> rowid=:rowid", rewritten:"/* contentdao.getrecord */ select * <table> rowid=?", arguments:{ positional:{}, named:{rowid:'row1'}, finder:[]}] 

if hard code table name, getting proper results. kindly help. thanks

you should annotate @usestringtemplate3statementlocator. discussed here.


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -