安装
创建用户
- 创建用户
# 创建linux用户
useradd gbase
# 设置新用户密码
passwd gbase
# 123456
- 赋予root权限
# 修改文件
vim /etc/sudoers
# 去点注释这两行的
## Allows people in group wheel to run all commands
# %wheel ALL=(ALL) ALL
# 将用户放入root分组
usermod -g root gbase
# 切换用户
su - gbase
安装
- 下载
http://www.gbase8a.com/Topic/173
wget http://www.gbase8a.com/forum.php?mod=attachment&aid=Mzc4fGI0MjQ3YzgwfDE2NDgwMjQ5MDN8ODU1MXw4MTY=&filename=GBase8a-8.6.2_build33-R3-rhel7.3--free.rar
- 加压
# 将 GBase8a-8.6.2_build33-R3-rhel7.3--free.rar 重新打包 GBase8a-8.6.2_build33-R3-rhel7.3--free.zip
unzip GBase8a-8.6.2_build33-R3-rhel7.3--free.zip
tar -xvf GBase8a-NoLicense-Free-8.6.2_build33-R3-redhat7.3-x86_64.tar.bz2
pwd
/home/gbase/GBase8a-8.6.2_build33-R3-rhel7.3--free/GBase8a-8.6.2_build33-R3-rhel7.3--free/GBaseInstall
- 安装
sh ./Install_lin.sh
# 许可协议选择Y
# 安装路径可以修改默认为~/GBase(即当前用户根目录下的GBase目录),按Enter
# 实例名默认为gbase8a,如果不修改按Enter
# 端口默认为5258,不修改按Enter
# 显示“Your GBase installation is successful.”时,表示您已成功安装了 GBase 8a 数据库
修改配置文件
# 在此文件中添加环境变量
vim /etc/profile
# 立即生效命令
source /etc/profile
新增
export GBASE_BASE=/home/gbase/GBase
export GBASE_HOME=/home/gbase/GBase/server
export GBASE_SID=gbase8a
export PATH=$GBASE_HOME/bin:$PATH
启动
su - gbase
cd /home/gbase/GBase/server/bin
./gbase.server start
# 出现以下
# Starting GBase. SUCCESS!
登录
# 登录
gbase -uroot
# 设置密码
gbase> SET PASSWORD FOR root = PASSWORD('123456');
# 退出
gbase> \q
# 再次登录
gbase -uroot -p
客户端
- 下载地址
https://www.gbase8s.com/index.php/gbase8s_tools.html
http://www.gbase8a.com/forum.php?mod=forumdisplay&fid=100
springboot整合
- 目录结构
├─java
│ └─com
│ └─gbase
│ └─gbase
│ ├─controller
│ └─mapper
└─resources
└─mapper
- 下载依赖
gbase-connector-java-8.3.81.53-build52.8-bin.jar
- 将依赖压入maven
mvn install:install-file -Dfile=D:\gbase-connector-java-8.3.81.53-build52.8-bin.jar -DgroupId=com.gbase.jdbc -DartifactId=gbase-connector-java -Dversion=8.3.81.53-build52.8-bin -Dpackaging=jar -DgeneratePom=true
- 引入依赖
<dependency>
<groupId>com.gbase.jdbc</groupId>
<artifactId>gbase-connector-java</artifactId>
<version>8.3.81.53-build52.8-bin</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-typehandlers-jsr310</artifactId>
</dependency>
- yml
server:
port: 8080
spring:
datasource:
url: jdbc:gbase://192.168.1.110:5258/test
username: root
password: 123456
driver-class-name: com.gbase.jdbc.Driver
#maximum-pool-size: 10
mybatis:
mapper-locations: classpath:mapper/**/*Mapper.xml
#type-aliases-package: com.yuanlai.entiy
- mybatis
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"./dtd/mybatis-3-config.dtd">
<configuration>
<settings>
<setting name="lazyLoadingEnabled" value="true"/>
<setting name="aggressiveLazyLoading" value="false"/>
</settings>
<typeAliases>
<typeAlias alias="Integer" type="java.lang.Integer"/>
<typeAlias alias="Long" type="java.lang.Long"/>
<typeAlias alias="String" type="java.lang.String"/>
<typeAlias alias="HashMap" type="java.util.HashMap"/>
<typeAlias alias="LinkedHashMap" type="java.util.LinkedHashMap"/>
<typeAlias alias="ArrayList" type="java.util.ArrayList"/>
<typeAlias alias="LinkedList" type="java.util.LinkedList"/>
</typeAliases>
</configuration>
- mapper.java
@Mapper
public interface TestMapper {
Integer findAll();
}
- mapper.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.gbase.gbase.mapper.TestMapper">
<select id="findAll" resultType="java.lang.Integer">
select count(*) from teacher;
</select>
</mapper>
- controller
@RestController
public class TestController {
@Autowired
TestMapper testMapper;
@GetMapping("/findAll")
public Integer findAll(){
return testMapper.findAll();
}
}
- 测试
http://localhost:8080/findAll