Closed liangbaika closed 2 years ago
你贴一下错误信息,周末我看看。
为了验证BeeCP是否支持Java17和Java18,编写简单的例子 如下
import cn.beecp.BeeDataSource;
import cn.beecp.BeeDataSourceConfig;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
public class MySqlTest {
public static void main(String[] args) throws Exception {
String driver = "com.mysql.cj.jdbc.Driver"; //mysql-connector-java-8.0.28.jar
String url = "JDBC:MYSQL://localhost/test"; //mysql-5.6.51-winx64
String user = "root";
String password = "";
Connection con1 = null;
Statement statement1 = null;
System.out.println("Java version:" + System.getProperty("java.version"));
try {
BeeDataSourceConfig config = new BeeDataSourceConfig();
config.setJdbcUrl(url);
config.setDriverClassName(driver);
config.setUsername(user);
config.setPassword(password);
BeeDataSource ds = new BeeDataSource(config);
con1 = ds.getConnection();
statement1 = con1.createStatement();
String testValue = "123456";
statement1.execute("insert into test values(" + testValue + ")");
System.out.println("SQL Complete");
} finally {
if (statement1 != null) statement1.close();
if (con1 != null) con1.close();
}
}
}
Java17测试截图
Java18测试截图
从上图的测试情况,BeeCP是可以获取到连接。你看能否分享一下你的出错信息和参数信息?
推荐使用使用最新版本看看
使用jdk17的时候 无法创建连接