springboot使用自帶連接池連接postgre


Application配置
spring.datasource.url=jdbc:postgresql://***:5432/postgres
spring.datasource.username=postgres
spring.datasource.password=123456
spring.datasource.driver-class-name=org.postgresql.Driver
#最大連接數
spring.datasource.tomcat.max-active=20
#最大空閑數
spring.datasource.tomcat.max-idle=8
#最小空閑數
spring.datasource.tomcat.min-idle=8
#初始化連接數
spring.datasource.tomcat.initial-size=10

注入jdbctemplate實現增刪改查
@Autowired
JdbcTemplate jdbcTemplate;
List<Path> paths = jdbcTemplate.query(start, new Object[]{projectid, projectid}, new RowMapper<Path>() {
@Override
public Path mapRow(ResultSet rs, int rowNum) throws SQLException {
double slng = rs.getDouble("slng");
double slat = rs.getDouble("slat");
double elng = rs.getDouble("elng");
double elat = rs.getDouble("elat");
Node snode = new Node();
snode.setLng(slng);
snode.setLat(slat);
Node enode = new Node();
enode.setLng(elng);
enode.setLat(elat);
Path path = new Path();
path.setStart(snode);
path.setEnd(enode);
return path;
}
});


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM