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

Capture and play voice with Asterisk ARI -

c++ - Can not find the "fiostream.h" file -

visual studio - Installing Packages through Nuget - "Central Directory corrupt" -