bind not for identifiers, but values. Table is a database object, and its name is the identifier for its reference.
Therefore, you must explicitly build the sql query string to dynamically include the table name.
An example :
String tableName = "employee"; String sql = "SELECT COUNT(*) FROM " + tableName;
Then, if you want to filter the score or any other results based on the value of a field or expression, you can link it.
An example :
sql = sql + " WHERE deptno = :deptNoToBind"; int deptNo = 20; // ... use db handle to bind handle.createQuery( sql ) .bind( "deptNoToBind", deptNo );
You can see that the values for columns or expressions are related, but not identifiers.
The function you are looking for is @Define - here is an example of its use:
import org.skife.jdbi.v2.sqlobject.customizers.Define; ... @SqlUpdate("create table if not exists <table> (" + "startTime TimeStamp not null," + "stopTime TimeStamp not null," + "uuid varchar(255)" + ")") public void createTable(@Define("table") String table);
Ravinder reddy
source share