'I'm trying to write tis code in spring boot way, how to write prepared statement in spring
I'm trying to write tis code in spring boot way, how to write prepared statement in spring
public static TechInfo getTechInfo(final Connection ttdb, final String meid){
//how to write this executeActionin spring method
return executeAction("getTechInfo " + meid, ttdb, new IDBAction<TechInfo>() {
@Override
public TechInfo execute(final Connection ttdb) {
// TODO Auto-generated method stub
TechInfo techInfo = null;
ResultSet resultSet = null;
PreparedStatement cs = null;
try {
cs = ttdb.prepareStatement(techInfoQry);
cs.setString(1, meid);
resultSet = cs.executeQuery();
if(resultSet != null){
//tmpMap = new ConcurrentHashMap<String, String>();
while (resultSet.next()) {
techInfo = new TechInfo();
techInfo.setVzid(resultSet.getString("VZID"));
techInfo.setMeid(meid);
techInfo.setTechtype(resultSet.getString("TECH_TYPE") != null ? resultSet.getString("TECH_TYPE") : "DEFAULT");
techInfo.setName(resultSet.getString("NAME"));
techInfo.setEid(resultSet.getString("EID"));
techInfo.setLastupdateTime(System.currentTimeMillis());
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
