Here you can find the source of getSQLErrorCode(SQLException ex_)
Parameter | Description |
---|---|
ex_ | the SQL exception |
static public int getSQLErrorCode(SQLException ex_)
//package com.java2s; /*L/*w ww . jav a 2 s.c om*/ * Copyright ScenPro Inc, SAIC-F * * Distributed under the OSI-approved BSD 3-Clause License. * See http://ncip.github.com/cadsr-sentinal/LICENSE.txt for details. */ import java.sql.SQLException; public class Main { /** * Sometimes the SQL error code isn't set and we have to pull it from the message. * * @param ex_ the SQL exception * @return the correct error code. */ static public int getSQLErrorCode(SQLException ex_) { int error = ex_.getErrorCode(); if (error != 0) return error; String msg = ex_.toString(); int pos = msg.indexOf("ORA-"); if (pos < 0) return -9999; pos += 4; String[] temp = msg.substring(pos).split("[:, ]"); if (temp.length < 2) return -9998; return Integer.valueOf(temp[0]); } }