📄 sqlstatesqlexceptiontranslate.java~40~
字号:
package com.bwm.stateclass;
import java.sql.SQLException;
import com.bwm.coreinterface.SQLExceptionTranslate;
import com.bwm.coreclass.CCException;
import com.bwm.coreclass.InalidDataAccessApiUsageException;
import com.bwm.coreclass.UncategorizedDataAccessException;
import com.bwm.coreclass.InalidDataAccessResourceUsageException;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2004</p>
* <p>Company: MR</p>
* @author BWM
* @version 1.0
*/
public class SQLStateSQLExceptionTranslate implements SQLExceptionTranslate {
public CCException translate(String task, String sql, SQLException sqlex) {
if (sqlex.getSQLState() != null) {
if (sqlex.getSQLState().equals("42000")||sqlex.getSQLState().equals("S1009")) {
throw new InalidDataAccessApiUsageException("["+task+"]: SQL error ["+sql+"]",sqlex);
}else if(sqlex.getSQLState().equals("S1002")){
throw new InalidDataAccessResourceUsageException("["+task+"]: SQL error ["+sql+"]",sqlex);
}
}
return new UncategorizedDataAccessException("["+task+"]: SQL error ["+sql+"]",sqlex);
}
public SQLStateSQLExceptionTranslate(String string, String string1,
SQLException sqlex) {
this.translate(string,sql,sqlex)
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -