different Sql state value for SQL server version



I am using java and connecting to SQL as backend.
Senario is as my code is trying to insert a row in table if the row exist i
will catch the SQLexception and update the row.
As per the code e.getSQLState() return's a value 23000 for 2000 and it is
not same for 2005.
catch ( SQLException e ){
if ( (e.getSQLState().trim().equals("23000") && e.getErrorCode() == 2601)
{
//update
}
else
//throw the exception
}
But as the value is changing with the version am not able to update. How to
resolve this.
.



Relevant Pages

  • Re: Wie Fehler zur Webseite durchreichen?
    ... Innerhalb der Funktion habe ich ein Try Catch (Catch sqlex As SqlException) welches mir eventuelle SQL Fehler abfängt. ... Wie gebe ich diese Fehler nun am besten runter zur Seite, ...
    (microsoft.public.de.german.entwickler.dotnet.asp)
  • jdbc ClassNotFoundException
    ... public DatabaseConnectionthrows SQLException, ClassNotFoundException ... public ResultSet runQuery(String sql) throws SQLException ... Statement statement = conn.createStatement; ...
    (comp.lang.java.programmer)
  • Re: Primary key error
    ... I would suggest that you use SQL Server Profiler to trace a problem case and capture the SQL statements that are issued. ... myCMD = New SqlCommand(mySQL, conn) ... Catch ae As SqlException ...
    (microsoft.public.sqlserver.server)
  • Re: ThreadAbortException thrown on certain machines...
    ... SqlException does seem to be thrown, it is a ThreadAbortException that gets ... The "ThreadAbortException" machine is does not have SQL ... Server installed but both machines are accessing a SQL ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Fehlercode bei Exception
    ... Hallo Andreas, ... Falls Du mit dem SQL Server arbeitest und es geschieht dort ein Fehler, ... ist die Exception normalerweise vom Typ SqlException und hat spezielle SQL ...
    (microsoft.public.de.german.entwickler.dotnet.datenbank)