瀚高数据库的安装
瀚高docker镜像安装
安装包获取链接:https://pan.baidu.com/s/1RxRhx-9Q8de9rCnAGaWM3w ( 提取码:2ln7) 镜像包版本:docker-hgdb4.5.8-see-x86-64-centos7-20230519.tar 镜像包安装步骤:
- 1.命名容器:--name=hgdb,这个参数指定容器为hgdb,也可以指定容器为hgdb,也可以指定其他容器识别的名称
- 2.宿主机端口:-p 5866:5866,容器内部端口是5866(第二个),-p后紧跟的是宿主机端口号,这里映射到宿主机端口号也是5866,可以指定其他端口号
- 3.存储映射:-v /home/hgdb:/opt/highgo/hgdb-see-4.5.9/data,将容器中的数据目录/opt/highgo/hgdb-see-4.5.9/data映射到宿主机的目录/home/hgdb下,这一参数是关键,务必要设置号否则会丢失数据
- 4.指定镜像名:hgdb-see:4.5.9是前面我们标记(TAG)的镜像名,要使用已经存在的镜像名
复制代码
瀚高数据库连接
后台连接数据库
默认用户:syssso syssao sysdba 初次登录都已默认设置连接免密
- alter user current_user password '*Admin_123';
复制代码
- create user postgres password '*Admin_123' valid until 'infinity';
复制代码
- create role postgres with superuser;
- alter role postgres WITH superuser;
复制代码
Springboot整合瀚高数据库
- 瀚高数据库maven依赖:
- <!--highgo jdbc-->
- <dependency>
- <groupId>com.highgo</groupId>
- <artifactId>HgdbJdbc</artifactId>
- <version>6.2.2</version>
- </dependency>
复制代码
- 瀚高数据库配置:
- spring:
- datasource:
- url: jdbc:highgo://206.206.127.190:5866/hgdb?currentSchema=schemaname
- username: sysdba
- password: admin_123
- driver-class-name: com.highgo.jdbc.Driver
复制代码
注:currentSchema表示指定的模式下的表数据 3. 测试连接数据库 - import com.highgo.jdbc.Driver;
- import lombok.extern.slf4j.Slf4j;
- import java.sql.*;
- import java.util.Properties;
- @Slf4j
- public class HgdbTest {
- static Connection conn = null;
- static String name = "com.highgo.jdbc.Driver";
- static String url = "jdbc:highgo://127.0.0.1:5866/highgo?currentSchema=schemaname";
- static String user = "sysdba";
- static String password = "admin_123";
- public static void main(String[] args) {
- // connect01();
- connect02();
- }
- public static void connect01() {
- try {
- //获取驱动
- Driver driver = new Driver();
- //获取连接
- String url = "jdbc:highgo://127.0.0.1:5866/highgo?currentSchema=schemaname";
- //将用户名和密码放入到Properities对象中
- Properties properties = new Properties();
- properties.setProperty("user", "sysdba");//用户
- properties.setProperty("password", "admin_123");//密码
- final Connection connect = driver.connect(url, properties);
- connect.setAutoCommit(false);
- System.out.println("连接成功" + url);
- } catch (Exception e) {
- log.error("连接异常,异常原因:{}", e.getMessage());
- }
- }
- public static void connect02() {
- try {
- Class.forName(name);
- conn = DriverManager.getConnection(url, user, password);
- conn.setAutoCommit(false);
- System.out.println("连接成功" + url);
- Statement statement = conn.createStatement();
- String sql1 = "select * from public."table";";
- ResultSet resultSet = statement.executeQuery(sql1);
- while (resultSet.next()) {
- String result = resultSet.getString(1);
- System.out.println(result);
- }
- } catch (Exception e) {
- System.out.println("error");
- }
- }
- }
复制代码
dbeaver连接瀚高数据库
瀚高数据库驱动:HgdbJdbc-6.2.2.jar
查询安装的dbeaver是否包含瀚高数据库驱动 初始不存在,则添加对应驱动,点击新建按钮:
注:驱动可从springboot整合瀚高数据库服务中获取:
目录路径为:maven本地存储库目录
新增瀚高数据库驱动成功后,可通过dbeaver连接瀚高数据库:
操作瀚高数据库
修改瀚高数据库默认端口为5432,
1)vi /opt/highgo/hgdb-see-4.5.8/data/postgresql.conf
2)修改 vi //opt/highgo/hgdb-see-4.5.8/bin/runpsql.sh 重启服务 |