Hi,
I am using spring boot jdbc template connecting to a phoenix hbase database.
However, i have a table with 100 columns. so, everytime when i insert a row should contain 100 values
For example insert:
public void insert(Ttsnihl m){
Object[] params = new Object[]{
m.getPATIENT_ID(),
m.getRECORD_DATE(),
m.getSTART_TIME(),
m.getEND_TIME(),
.....// 100 object array
};
jdbcTemplate.update(insertSql, params);
}
And:
public void insertBatch(final List<Ttsnihl> ts){
BatchPreparedStatementSetter bpss = new BatchPreparedStatementSetter() {
@Override
public void setValues(PreparedStatement ps, int i) throws SQLException {
Ttsnihl t=ts.get(i);
ps.setString(1, t.getPATIENT_ID());
ps.setTimestamp(2, t.getRECORD_DATE());
ps.setTimestamp(3, t.getSTART_TIME());
ps.setTimestamp(4, t.getEND_TIME());
..... // 100 ps.set()functions
}
@Override
public int getBatchSize() {
return ts.size();
}
};
jdbcTemplate.batchUpdate(insertSql, bpss);
}
I want to ask, is there any smart way to do this?
Many thanks in advance!