简体   繁体   中英

How to get full sql script with replaced wild cards in jdbcTemplate?

I have following code

public class Foo{

    private final NamedParameterJdbcTemplate nJdbcTemplate;

    public void bar(....){
         String query = "INSERT INTO ....
         ....
         nJdbcTemplate.batchUpdate(query, mapSqlParameterSourcesArray);
    }

}

I want to get full , valid insert SQL script to insert it into another database.

Is there way to achieve it in spring jdbc template?

Not in the jdbc template.

It's not the jdbc template who's doing the placeholder replacement. It's the JDBC driver (or it could even be the database server!). Take a look at the PreparedStatement interface - the parameters are actually passed in different methods than the statement is.

(While this interface does not allow for named parameters, the documentation states that Spring translates the named parameters to ? making it suitable input for this interface.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM