我正在使用 postgresql,但在从数据库表中获取记录时,我收到此异常致命:抱歉,客户端太多
。
下面是连接类:
<context:component-scan base-package="com.trinity" />
<context:property-placeholder location="classpath:/jdbc.properties" order="1" ignore-unresolvable="true"/>
<beans:bean id="dataSourcePOSTGRESQL" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<beans:property name="driverClassName" value="${pg_jdbc.driverClassName}" />
<beans:property name="url" value="${pg_jdbc.url}" />
<beans:property name="username" value="${pg_jdbc.username}" />
<beans:property name="password" value="${pg_jdbc.password}" />
</beans:bean>
jdbc.propertis
pg_jdbc.driverClassName=org.postgresql.Driver
pg_jdbc1.url1=jdbc:postgresql://localhost:5433/iotdb
pg_jdbc.username=postgres
pg_jdbc.password=track@123
Dao 类:
public List<Map<String, Object>> getAllDevicesNames(Integer companyId) {
String sql = "select device_configuration_id,device_name,device_id from iot.device_configuration where company_id = ? ";
List<Map<String, Object>> queryForList = jdbcTemplate.queryForList(sql,new Object[]{companyId});
return queryForList;
}
最佳答案
之前在我的 postgres.cfg 文件中
max_connections = 100
shared_buffers = 128kb
现在,我更改为
max_connections = 300
shared_buffers = 80MB
工作正常。
关于java - Postgres+JDBC 模板太多客户端已经异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40755884/