gpt4 book ai didi

java - 找不到符号 ds.setMaxActive(MAX_ACTIVE);

转载 作者:太空宇宙 更新时间:2023-11-04 09:37:54 24 4
gpt4 key购买 nike

我正在尝试使用 Commons DBCP 配置 Oracle 数据源,但它抛出主题错误

我正在 CentOS 上工作


private String driverClassName="oracle.jdbc.driver.OracleDriver" ;
private String url="jdbc:oracle:thin:@164.173.28.18:1521:XE";
private String userName="username";
private String password="password";
private static int MAX_ACTIVE= 10;
private BasicDataSource ds = null;

public void init() throws SQLException{
ds = new BasicDataSource();
ds.setDriverClassName(driverClassName);
ds.setPassword(password);
ds.setUsername(userName);
ds.setUrl(url);
ds.setMaxActive(MAX_ACTIVE);
//check connections
ds.getConnection();
}


public Connection getOracleConnection() throws SQLException{
return ds.getConnection();
}

如何修复

DB.java:27: error: cannot find symbol
ds.setMaxActive(MAX_ACTIVE); ^
symbol: method setMaxActive(int)
location: variable ds of type BasicDataSource
1 error

最佳答案

显然,您的数据源类不支持maxactive .

您需要检查您的库版本。

关于java - 找不到符号 ds.setMaxActive(MAX_ACTIVE);,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56282056/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com