连接不可用,请求在 30002 毫秒后超时

Connection is not available, request timed out after 30002ms

成功运行申请后,我遇到了连接错误。我的代码如下。我使用的是高效的连接处理,还是需要改进它? 运行 应用程序时,我在哪里可以看到我的活动、已用和空闲连接状态?

@Service
public class printChallan extends JdbcDaoSupport{

@Autowired
DataSource dataSource;

@PostConstruct
private void initialize() {setDataSource(dataSource);}

public boolean printAdmissionForm(HttpServletRequest request)
{
    java.sql.Connection conn = null;
    try {
            conn = getJdbcTemplate().getDataSource().getConnection();
            //conn = dataSource.getConnection();
            jasperdesign = JRXmlLoader.load(totalPath);
            JasperReport jasperReport = JasperCompileManager.compileReport(jasperdesign);
            jasperPrint = JasperFillManager.fillReport(jasperReport, param, conn);
        } catch (Exception e) 
        {
           if(conn != null) conn.close(); // Does I need to close Connection Manually
            e.printStackTrace();
        }
return true;
}
public boolean callProcedure(HttpServletRequest request){
CallableStatement cs = null;
try 
{
   cs = getJdbcTemplate().getDataSource().getConnection()   // does this connection need to be closed.
   .prepareCall("{? = call FUNC_CHALLAN_PRINT_TYPE(?)}");
    cs.registerOutParameter(1, Types.VARCHAR);
    cs.setString(2, challanNbr);
    cs.execute();
    Status = cs.getString(1);
    cs.close();
    return Status;
} catch (SQLException e) {
            logger.debug("Error occured while getting Challan record" + e.getMessage());
}finally
{

}
return true;
}
}

Application.properties

spring.datasource.url=jdbc:oracle:thin:@172.19.10.37:1521:ORCL
spring.datasource.username=app
spring.datasource.password=app
spring.datasource.platform=ORACLE

如果您不关闭连接,池将已满,并且您在尝试获得新连接时会超时。

您没有关闭连接,只需更改为 try-with-resources 即可自动关闭

try (java.sql.Connection conn = getJdbcTemplate().getDataSource().getConnection()) {

CallableStatement

的相同解决方案