Mybatis Plus适配Oracle

1. 准备数据库数据:

用navicat导入传输数据后,存在表名、列名大小写问题,需要将其转换成默认大写样式

Oracle触发器:

DECLARE
    v_tablename_x VARCHAR2(200);
    v_tablename_d VARCHAR2(200);
begin
    v_tablename_x:='auth_role_function_relation';  ------原始表名
    v_tablename_d:='AUTH_ROLE_FUNCTION_RELATION'; ------目标表名
    for c in (select COLUMN_NAME cn from all_tab_columns where table_name=v_tablename_x) loop
    begin
        execute immediate 'alter table "'||v_tablename_x||'" rename column "'||c.cn||'" to '||c.cn;
        exception
        when others then
        dbms_output.put_line(v_tablename_x||'.'||c.cn||'已经存在');
    end;
    end loop;
    execute immediate 'alter table "'||v_tablename_x||'" rename to '||v_tablename_d||'';
    exception
    when others then
    dbms_output.put_line(v_tablename_d||'已存在');
end;

2. 本地项目jar包引入

下载Oracle jar包,本地mvn install (具体存放路径根据自己修改)

mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc19 -Dversion=19.3.0.0 -Dpackaging=jar -Dfile=D:/maven/repository/com/oracle/ojdbc8.jar

pom文件引入jar包
在这里插入图片描述

3. 修改配置文件

修改sqlType以及oracle配置

在这里插入图片描述

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
MyBatis Plus 默认支持 PostgreSQL 数据库,无需额外适配。在使用时只需要设置对应的数据源、配置文件和实体类映射即可。以下是一个简单的示例: 1. 添加依赖 ```xml <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> <version>最新版本</version> </dependency> <dependency> <groupId>org.postgresql</groupId> <artifactId>postgresql</artifactId> <version>42.2.23</version> </dependency> ``` 2. 配置数据源 ```properties spring.datasource.url=jdbc:postgresql://localhost:5432/mydb spring.datasource.username=postgres spring.datasource.password=123456 spring.datasource.driver-class-name=org.postgresql.Driver ``` 3. 配置 MyBatis Plus 在 MyBatis Plus 的配置文件中,需要设置一些 PostgreSQL 特有的参数,例如数组类型的映射、标识符的转义等。 ```properties # 配置数组类型的映射 mybatis.type-handlers-package=com.baomidou.mybatisplus.extension.handlers # 配置标识符的转义 mybatis.configuration.map-underscore-to-camel-case=true mybatis.configuration.jdbc-type-for-null=null mybatis.configuration.local-cache-scope=STATEMENT mybatis.configuration.cache-enabled=false mybatis.configuration.default-fetch-size=100 mybatis.configuration.default-statement-timeout=30 mybatis.configuration.default-executor-type=reuse mybatis.configuration.default-auto-mapping=JDBC mybatis.configuration.default-statement-type=PREPARED mybatis.configuration.default-use-column-label=true mybatis.configuration.default-use-generated-keys=false mybatis.configuration.default-statement-result-type=HASH_MAP mybatis.configuration.default-scripting-language=VelocitySQL mybatis.configuration.default-enum-type-handler=org.apache.ibatis.type.EnumOrdinalTypeHandler mybatis.configuration.default-map-type-handler=org.apache.ibatis.type.MapTypeHandler mybatis.configuration.default-date-type-handler=org.apache.ibatis.type.DateTypeHandler mybatis.configuration.default-calendar-type-handler=org.apache.ibatis.type.CalendarTypeHandler mybatis.configuration.default-numeric-type-handler=org.apache.ibatis.type.BigDecimalTypeHandler mybatis.configuration.default-lob-handler=com.baomidou.mybatisplus.extension.handlers.OracleLobHandler mybatis.configuration.default-boolean-type-handler=org.apache.ibatis.type.BooleanTypeHandler mybatis.configuration.default-byte-type-handler=org.apache.ibatis.type.ByteTypeHandler mybatis.configuration.default-short-type-handler=org.apache.ibatis.type.ShortTypeHandler mybatis.configuration.default-integer-type-handler=org.apache.ibatis.type.IntegerTypeHandler mybatis.configuration.default-long-type-handler=org.apache.ibatis.type.LongTypeHandler mybatis.configuration.default-float-type-handler=org.apache.ibatis.type.FloatTypeHandler mybatis.configuration.default-double-type-handler=org.apache.ibatis.type.DoubleTypeHandler mybatis.configuration.default-string-type-handler=org.apache.ibatis.type.StringTypeHandler mybatis.configuration.default-byte-array-type-handler=org.apache.ibatis.type.ByteArrayTypeHandler mybatis.configuration.default-object-type-handler=org.apache.ibatis.type.ObjectTypeHandler mybatis.configuration.default-clob-type-handler=org.apache.ibatis.type.ClobTypeHandler mybatis.configuration.default-reader-type-handler=org.apache.ibatis.type.ReaderTypeHandler mybatis.configuration.default-input-stream-type-handler=org.apache.ibatis.type.InputStreamTypeHandler mybatis.configuration.default-blob-type-handler=org.apache.ibatis.type.BlobTypeHandler mybatis.configuration.default-uuid-type-handler=org.apache.ibatis.type.EnumOrdinalTypeHandler mybatis.configuration.default-time-zone=GMT+8 ``` 4. 配置实体类映射 在实体类的属性上使用注解或配置文件来映射数据库字段。例如: ```java @Data public class User { @TableId private Long id; @TableField("user_name") private String userName; private Integer age; } ``` ```xml <!-- 配置实体类映射 --> <bean id="userMapper" class="com.baomidou.mybatisplus.core.mapper.BaseMapper"> <property name="entityClass" value="com.example.User"/> <property name="mapperClass" value="com.example.UserMapper"/> <property name="sqlSessionFactory" ref="sqlSessionFactory"/> </bean> ``` 以上就是在 MyBatis Plus 中适配 PostgreSQL 数据库的基本步骤。如果有更复杂的需求,可以参考官方文档或在社区中寻求帮助。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值