key转换为大写/小写
重写ColumnMapRowMapper
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public class JdbcTests {
JdbcTemplate jdbcTemplate = new JdbcTemplate();
@BeforeAll
public void before() {
MysqlDataSource dataSource = new MysqlDataSource();
dataSource.setPort(3306);
dataSource.setUser("root");
dataSource.setPassword("@@@@@");
dataSource.setServerName("39.97.243.43");
jdbcTemplate.setDataSource(dataSource);
}
@Test
@SneakyThrows
public void a1() {
String sql = "select * from test.demo";
List<Map<String, Object>> query = jdbcTemplate.query(sql, new ColumnMapRowMapper(){
protected String getColumnKey(String columnName) {
return columnName.toUpperCase();
}
});
System.out.println(query);
}
}