2022-11-18
opengauss JDBC 连接全密态数据库,参数设置enable_ce=1不生效
环境是在Ubuntu上,用intelij idea
opengauss版本是openGauss_3.1.0 企业版
jar包是gsjdbc4.jar,是从华为控制中心下载的8.1.x版本
项目里的代码是从opengauss文档里copy的示例代码:
但一直报错Un-support to create client master key when client encryption is disabled
jar包我把上述下载链接里的所有版本都试过了,都是这个问题,jdbc可以正常连接数据库,gsql也可以正常使用全密态操作,感觉很疑惑。
package org.opengauss;
import java.sql.*;
import java.util.Properties;
public class connectsql {
//以下代码将获取数据库连接操作封装为一个接口,可通过给定用户名和密码来连接数据库。
public static Connection getConnect(String username, String passwd)
{
//驱动类。
String driver = "org.postgresql.Driver";
//数据库连接描述符。
String sourceURL = "jdbc:postgresql://192.168.62.128:5430/postgres?enable_ce=1";
Connection conn = null;
Properties info = new Properties();
try
{
//加载驱动。
info.setProperty("enable_ce","1");
info.setProperty("user",username);
info.setProperty("password",passwd);
Class.forName(driver);
}
catch( Exception e )
{
e.printStackTrace();
return null;
}
try
{
//创建连接。
conn = DriverManager.getConnection(sourceURL, info);
System.out.println("Connection succeed!");
}
catch(Exception e)
{
e.printStackTrace();
return null;
}
return conn;
};
public static void main(String[] args) throws SQLException {
// TODO 自动生成的方法存根
new connectsql();
Connection myconnection = connectsql.getConnect("alice","demo@123");
Statement stmt = myconnection.createStatement();
int rc = stmt.executeUpdate("CREATE CLIENT MASTER KEY
}
}
我来答
添加附件
收藏
分享
问题补充
4条回答
默认
最新
回答交流
提交
问题信息
请登录之后查看
邀请回答
暂无人订阅该标签,敬请期待~~
墨值悬赏


评论


