• 为顶替考试者苟晶班主任邱老师,说几句公道话!


    http://bbs.tianya.cn/post-worldlook-1936355-1.shtml

    package com.example.errorcodedemo;
    
    import org.springframework.dao.DuplicateKeyException;
    
    public class CustomDuplicatedKeyException extends DuplicateKeyException {
        public CustomDuplicatedKeyException(String msg) {
            super(msg);
        }
    
        public CustomDuplicatedKeyException(String msg, Throwable cause) {
            super(msg, cause);
        }
    }
    
    
    package com.example.errorcodedemo;
    
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    
    /**
     * 自定义错误码(h2)
     * 详见Tests
     */
    @SpringBootApplication
    public class ErrorcodeDemoApplication {
    
        public static void main(String[] args) {
            SpringApplication.run(ErrorcodeDemoApplication.class, args);
        }
    
    }
    
    
    CREATE TABLE FOO (ID INT IDENTITY, BAR VARCHAR(64));
    
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
    
    <beans>
    
        <bean id="H2" class="org.springframework.jdbc.support.SQLErrorCodes">
            <property name="badSqlGrammarCodes">
                <value>42000,42001,42101,42102,42111,42112,42121,42122,42132</value>
            </property>
            <property name="duplicateKeyCodes">
                <value>23001,23505</value>
            </property>
            <property name="dataIntegrityViolationCodes">
                <value>22001,22003,22012,22018,22025,23000,23002,23003,23502,23503,23506,23507,23513</value>
            </property>
            <property name="dataAccessResourceFailureCodes">
                <value>90046,90100,90117,90121,90126</value>
            </property>
            <property name="cannotAcquireLockCodes">
                <value>50200</value>
            </property>
            <property name="customTranslations">
                <bean class="org.springframework.jdbc.support.CustomSQLErrorCodesTranslation">
                    <property name="errorCodes" value="23001,23505" />
                    <property name="exceptionClass"
                              value="com.example.errorcodedemo.CustomDuplicatedKeyException" />
                </bean>
            </property>
        </bean>
    
    </beans>
    
    
  • 相关阅读:
    Java String, StringBuffer和StringBuilder实例
    java中字符串的比较
    java中子类继承父类时是否继承构造函数
    Java中抽象类和接口的用法和区别
    与(&)、非(~)、或(|)、异或(^)
    Linux03
    Linux02
    Linux01
    力扣算法题
    算法 栈、队列、二分查找
  • 原文地址:https://www.cnblogs.com/ukzq/p/13284353.html
Copyright © 2020-2023  润新知