R
R
Romanov19812020-10-16 16:42:28
MySQL
Romanov1981, 2020-10-16 16:42:28

JdbcTemplate dynamic table name?

Greetings dear forum users.

Please tell me how to make it so that the name of the table can be passed in the parameters of the method argument? and then the question mark =? does not fit.

public String getFieldFromEntityWhereValue(String selectField, String fromEntity, String whereValue) {
        String sql = "SELECT email=? FROM user WHERE token=?";
        return jdbcTemplate.queryForObject(sql, new Object[] { selectField, fromEntity, whereValue}, String.class);
    }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2020-10-16
@Romanov1981

No way. And in any correct scenarios for using a relational database, this cannot be needed.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question