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