X

Proactive insights, news and tips from Oracle Fusion Middleware Support. Learn Oracle from Oracle.

Configuring Datasource Fatal Error Codes

Stephen Felts
Manager

There
are well known error codes on JDBC operations that can always be interpreted as
the database shutting down, already down, or a configuration problem.
  In this case, we don’t want to keep the
connection around because we know that subsequent operations will fail and they
might hang or take a long time to complete.
These error codes can be
configured in the datasource configuration using the "fatal-error-codes"
value on the Connection Pool Parameters. The value is a comma separated list of error codes.
  If
a SQLException is seen on a JDBC operation and sqlException.getErrorCode()
matches one of the configured codes, the connection will be closed instead of
returning it to the connection pool.

Note that in the earlier OC4J application
server, it closed all connections in the pool when one of these errors occurred
on any connection. In the WLS implementation, we chose to only close the
connection that got the fatal error.  This allows you to add some error codes that are specific to a connection going bad in addition to the database being unavailable.

The following error codes are pre-configured and
cannot be disabled. You can provide additional
error codes for these or other drivers on individual datasources.

Driver
Type

Default
Fatal Error Codes

Oracle Thin Driver

3113, 3114, 1033, 1034, 1089, 1090, 17002

WebLogic or IBM DB2 driver

-4498, -4499, -1776, -30108, -30081, -30080,
-6036, -1229, -1224, -1035, -1034, -1015, -924, -923, -906, -518, -514, 58004

WebLogic or IBM Informix driver

-79735, -79716, -43207, -27002, -25580, -4499,
-908, -710, 43012

The following is a WLST script to add a fatal error
code string to an existing datasource.

# java weblogic.WLST fatalerrorcodes.py

import sys, socket, os

hostname = socket.gethostname()

datasource="JDBC GridLink Data Source-0"

connect("weblogic","welcome1","t3://"+hostname+":7001")

edit()

startEdit()

cd("/JDBCSystemResources/" + datasource )

targets=get("Targets")

set("Targets",jarray.array([], ObjectName))

save()

activate()

startEdit()

cd("/JDBCSystemResources/" + datasource + "/JDBCResource/"
+
datasource +
"/JDBCConnectionPoolParams/" + datasource )

set("FatalErrorCodes","1111,2222")

save()

activate()

startEdit()

cd("/JDBCSystemResources/" + datasource )

set("Targets", targets)

save()

activate()

As an experiment, I tried this with REST.

localhost=localhost

editurl=http://${localhost}:7001/management/weblogic/latest/edit

name="JDBC%20GridLink%20Data%20Source%2D0"


curl -v \

--user weblogic:welcome1 \

-H X-Requested-By:MyClient \

-H Accept:application/json \

-X GET \

${editurl}/JDBCSystemResources/${name}/JDBCResource/JDBCConnectionPoolParams?links=none"

curl -v \

--user weblogic:welcome1 \

-H X-Requested-By:MyClient \

-H Accept:application/json \

-H Content-Type:application/json \

-d "{}" \

-X POST "${editurl}/changeManager/startEdit"

curl -v \

--user weblogic:welcome1 \

-H X-Requested-By:MyClient \

-H Accept:application/json \

-H Content-Type:application/json \

-d "{
targets: []

}" \

-X POST "${editurl}/JDBCSystemResources/${name}"

curl -v \

--user weblogic:welcome1 \

-H X-Requested-By:MyClient \

-H Accept:application/json \

-H Content-Type:application/json \

-d "{
fatalErrorCodes: '1111,2222'

}" \

-X POST \

"${editurl}/JDBCSystemResources/${name}/JDBCResource/JDBCConnectionPoolParams"

curl -v \

--user weblogic:welcome1 \

-H X-Requested-By:MyClient \

-H Accept:application/json \

-H Content-Type:application/json \

-d "{
targets: [ { identity: [ servers,
'myserver' ] } ]

}" \

-X POST "${editurl}/JDBCSystemResources/${name}"

curl -v \

--user weblogic:welcome1 \

-H X-Requested-By:MyClient \

-H Accept:application/json \

-H Content-Type:application/json \

-d "{}" \

-X POST "${editurl}/changeManager/activate"

curl -v \

--user weblogic:welcome1 \

-H X-Requested-By:MyClient \

-H Accept:application/json \

-X GET "${editurl}/JDBCSystemResources/${name}?links=none"

Join the discussion

Comments ( 2 )
  • M. R. Tuesday, December 27, 2016

    So, what exactly do these error codes correspond to? Could you please provide us with a link to some documentation articulating what each of the error codes mean.


  • Stephen Felts Tuesday, December 27, 2016

    The list of error codes that are pre-configured were determined by experts in the related Oracle and IBM database teams. Please refer to the documentation for the Oracle, IBM DB2, and IBM Informix databases.


Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.Captcha
Oracle

Integrated Cloud Applications & Platform Services