Make Dynamic Query with JdbcTemplate

后端 未结 1 459
盖世英雄少女心
盖世英雄少女心 2021-01-27 06:20

I have one question regarding make dynamic query with JdbcTemplate.

My code is as below :

String insertQueries = \"INSERT INTO \" + tablename;

StringJoi         


        
相关标签:
1条回答
  • 2021-01-27 07:05
    **StringJoiner joiner2 = new StringJoiner(",", "(", ")");**
    while (mapIterator.hasNext()) {
    
     //change in value1 as
    value = "\"" + (String) mapEntry.getValue() +  "\"";
     value1 = joiner2.add(value);
     myvalue = joiner2.add("?");
    

    }

     //change  insertQueries  as with value as (? ,?)
    insertQueries += " VALUES "+ myvalue+"" ;
    
    
    //get value1 as  ("abc", "xyz") 
    
    //update query as
    int row = jdbcTemplate.update(insertQueries, value1);
    
    0 讨论(0)
提交回复
热议问题