Troubleshooting: Database connectivity for Oracle databases
You can encounter database connectivity issues when you are connecting to an Oracle database to create instances, apply fix packs, enable features, or when you run many WebSphere Commerce utilities. To resolve these connectivity issues, validate your configured database connection settings and ensure that you are using the correct JDBC driver configuration. Review the following information about connecting to Oracle databases, including common connectivity errors, to help you validate your settings and troubleshoot problems.
- Validate whether you can establish a database connection
- Validate the Oracle client environment access
- Validate that a database connection can be established with the JDBC type 4 and type 2 drivers
- Validate the database connection acquisition framework configuration
- Validate the WebSphere Application Server database connection
- Validate the SID or service name parameters
- Common connection errors
Validate whether you can establish a database connection
If you encounter errors when a WebSphere Commerce utility or process that involves database-related operations runs, use the database connection validation utility to ensure that a database connection established. By default, this validation utility runs as part of the process for some utilities and processes. You can run this utility by itself to validate that a database connection can be properly established with the parameters that are configured for your WebSphere Commerce instance.
When the utility completes running, a detailed report generates that indicates whether a successful database connection can be established with the specified connection parameters. The report also indicates whether any errors occurred. For more information about this utility, see Running the database connection validation utility.
wcsDbValidation.sh -jdbcURL <jdbc_url> -jdbcDriver oracle.jdbc.OracleDriver -dbUserName <user> -dbUserPassword <password>
For
example, the following command is for validating a connection that uses a type 4 connection type
that includes the Oracle SID
value:wcsDbValidation.sh -jdbcURL jdbc:oracle:thin:@myhostname:1521:orcl -jdbcDriver oracle.jdbc.OracleDriver -dbUserName wcs -dbUserPassword password
The
following command is for validatin a connection that uses a type 2 connection
type:wcsDbValidation.sh -jdbcURL jdbc:oracle:oci:@orcl -jdbcDriver oracle.jdbc.OracleDriver -dbUserName wcs -dbUserPassword password
- To validate a connection with the SQL*Plus command line utility, you can use a command that uses
the following format:
Wheresqlplus user/password@<NET_SERVICE_NAME>
NET_SERVICE_NAME
is one of the aliases that are defined in tnsnames.ora. If you are not able to use SQL*Plus with the non-root user profile, you might need to set the Oracle environment variables.You can also bypass the tnsnames.ora configuration and specify the connection arguments directly in the SQL*Plus command line:- Connecting by
SID:
sqlplus <USER>/<PASSWORD>@"(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=<HOST>)(PORT=<PORT>))(CONNECT_DATA=(SID=<SID>)))"
- Connecting by
Service:
sqlplus <USER>/<PASSWORD>@"(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=<HOST>)(PORT=<PORT>))(CONNECT_DATA=(SERVICE_NAME=<SERVICE>)))"
sqlplus <USER>/<PASSWORD>@<HOST>:<PORT>/<SERVICE>
- Connecting by
SID:
- To validate a connection to the listener with the tnsping utility from a command-line utility,
use a command with the following format:
For more information, see Using the Oracle TNSPING utility to test connectivity from the client.[oracle@myhostname 11.2.0]$ tnsping "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=myhostname)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=orcl)))" TNS Ping Utility for Linux: Version 11.2.0.3.0 - Production on 13-APR-2015 11:30:25 Copyright (c) 1997, 2011, Oracle. All rights reserved. Attempting to contact (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=myhostname)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=orcl))) OK (10 msec)
Validate the Oracle client environment access
Ensure that you can access your Oracle client environment from WebSphere Commerce. The Oracle client provides the necessary libraries to connect WebSphere Commerce to the Oracle database server, including the required Java JDBC Drivers and database connection configuration.
sqlplus user/password@<NET_SERVICE_NAME> ( The net service name is defined in tnsnames.ora)
If
the SQL*Plus (sqlplus) command is not found, the client might not be configured correctly. Ensure
that the following environment variables are correct: Environment Variable | Usage |
---|---|
ORACLE_BASE | Base path for the Oracle install. For example, /opt/oracle/u01/app/oracle |
ORACLE_HOME | Base directory to the Oracle database in use: $ORACLE_BASE/product/11.2.0/db_1 |
PATH | Add an Oracle binary file to the path. Oracle_installdir/bin |
LD_LIBRARY_PATH | Include Oracle libraries in the library path: Oracle_installdir/lib |
[wasuser@myhostname bin]$ . ./setenv.sh
[wasuser@myhostname bin]$ set | grep ORACLE
ORACLE_CLASSPATH=/opt/oracle/u01/app/oracle/product/11.2.0/db_1/jdbc/lib/ojdbc6.jar
ORACLE_BASE=/opt/oracle/u01/app/oracle
ORACLE_HOME=/opt/oracle/u01/app/oracle/product/11.2.0/db_1
ORACLE_LIBPATH=/opt/oracle/u01/app/oracle/product/11.2.0/db_1/lib:/opt/oracle/u01/app/oracle/product/11.2.0/db_1/lib
If
the variables are incorrect, your Oracle client might not be installed in the expected directory. To
view the expected directory, review the configured setting in the
WC_installdir/xml/product.xml file. The Oracle client
installation directory is typically configured during WebSphere Commerce installation. [wasuser@myhostname oracle]$ cat /u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora
# tnsnames.ora Network Configuration File: /opt/oracle/u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = myhostname)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
Validate that a database connection can be established with the JDBC type 4 and type 2 drivers
WebSphere Commerce supportes the use of both the JDBC type 2 (thick) driver and the JDBC type 4 (thin) driver for connecting to a database. Ensure that you can establish a connection with both types of driver.
WebSphere Commerce uses the ojdbc6.jar JDBC type 4 driver for connecting to an Oracle database. This type 4 driver is an upgrade from the type 2 driver and provides improved performance and a richer set of functions for creating database connections. This upgrade includes both the runtime data source connections and the utilities connections, such as staging utilities, loading utilities, dbclean, and acpload.
- JDBC URL format when you use the
SID:
jdbc:oracle:thin:@<HOST>:<PORT>:<SID>
- JDBC URL format when you use the service
name:
jdbc:oracle:thin:@//<HOST>:<PORT>/<SERVICE>
Although you can still use the type 2 connection type, this syntax is converted internally to type 4 syntax and a type 4 database connection is created. The type 2 connection type is more error prone that the type 4 connection type since with the type 2 driver, Java needs access to your native Oracle client. To avoid a potential performance impact due to the conversion, use the type 4 connection type database name syntax.
jdbc:oracle:oci:@<NET_SERVICE_NAME>
Validate the database connection acquisition framework configuration
- JDBC
URL
dbclean.sh -dbtype oracle -db jdbc:oracle:thin:@myhostname:1521:orcl -object cacheivl -type obsolete -days 1 -instancexml WC_installdir/instances/demo/xml/demo.xml -dbuser wcs -dbpasswd password 20150413-103654| AllDBConnector.connect> Determined database-type from input: [oracle] as: [Oracle] 20150413-103654| AllDBConnector.connectOracle> Attempting to load Oracle JDBC driver: [oracle.jdbc.OracleDriver] 20150413-103654| AllDBConnector.connectOracle> Attempting to acquire Oracle Connection using URL: [jdbc:oracle:thin:@myhostname:1521:orcl] 20150413-103655| AllDBConnector.connectOrFail> Connection acquired
- Service
name
dbclean.sh -dbtype oracle -db orcl -object cacheivl -type obsolete -days 1 -instancexml WC_installdir/instances/demo/xml/demo.xml -dbuser wcs -dbpasswd password 20150413-103444| AllDBConnector.connect> Determined database-type from input: [oracle] as: [Oracle] 20150413-103444| AllDBConnector.connectOracle> Attempting to load Oracle JDBC driver: [oracle.jdbc.OracleDriver] 20150413-103445| AllDBConnector.connectOracle> Attempting to acquire Oracle Connection using URL: [jdbc:oracle:oci:@orcl] 20150413-103445| AllDBConnector.connectOrFail> Connection acquired
To resolve connectivity issues that you encounter if your utilities use the database connection acquisition framework, ensure that the connection settings in the alldbconnector.xml configuration file are correct. When you are reviewing your database connection acquisition configuration, check for any configured overrides that can be causing your connectivity problem. The framework provides you with the capability to set override options that can affect all database connections for utilities. For more information about the settings and overrides in this file, see Database connection acquisition for utilities and Ant tasks.
- SQL*Plus with the net service name:
sqlplus user/password@<NET_SERVICE_NAME>
- WebSphere Commerce database validation utility with the JDBC
URL:
wcsDbValidation.sh -jdbcURL <jdbc_url> -jdbcDriver oracle.jdbc.OracleDriver -dbUserName <user> -dbUserPassword <password>
Validate the WebSphere Application Server database connection
- In the WebSphere Application Server administration console, expand The console includes a JDBC tester, which can you can use to help you validate your settings by testing the connection that uses the configured JDBC settings.Note: You can change the connection URL if needed. For example, if you want to use a SCAN IP and service, such as jdbc:oracle:thin:@//rac-scan:port/rac-service-name.
. Review and verify the type 4 driver connection type settings.
- Review and verify your user name and password settings that are associated with the connection type settings. For example, if you encounter an error that your user ID and password are invalide, you might need to update your password. The user name and password settings are listed in the JAAS - J2C authentication record that is associated with the selected data source. For more information, see Changing database passwords.
- If you are working within an authoring environment, you can also see a data source for publishing data. This data source typically has the production database connection parameters for publishing data. Review and verify the connection settings for this data source.
Validate the SID or service name parameters
- SID:
ORCL = (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=myhostname)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SID=orcl)))
- Service:
ORCL = (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=myhostname)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)))
jdbc:oracle:thin:@//rac-scan:port/rac-service-name
For more
information, see: - Using Oracle Real Application Clusters (RAC) with WebSphere Commerce
- Installing and configuring a new Oracle RAC database
- Using Oracle Real Application Clusters (RAC) with WebSphere Commerce
- Installing and configuring a new Oracle RAC database
Common connection errors
The following errors are examples of common connection problems that you might encounter. To help resolve these problems and other connectivity problems, review any error message that generates when you encounter a problem. For more information, see Database error messages.-
The JDBC driver class cannot be found.
You can encounter a connectivity error if Java cannot find the ojdbc6.jar JAR file for for the JDBC driver. Java needs to find the JAR file to use the oracle.jdbc.OracleDriver driver class. This error can resemble the following error message:
Ensure that the JAR file is in the expected directory. The JAR file is expected to be in the Oracle_installdir/jdbc/lib directory. You can encounter this error when the JAR file is not in the expected directory. For example, if the Oracle client is not installed in the location that was specified during WebSphere Commerce installation. Review the WC_installdir/xml/product.xml file to identify the expected installation location for the Oracel client.java.lang.ClassNotFoundException:oracle.jdbc.OracleDriver at java.lang.Class.forName(Class.java:185) at com.ibm.commerce.config.ant.WcsDbValidation.testJdbcDriverClass(WcsDbValidation.java:665)
- The native Oracle client libraries cannot be found.If you use the Oracle JDBC type 2 driver, you can encounter an error if Java cannot locate the native Oracle client libraries. This error can resemble the following error message:
Ensure that the LD_LIBRARY_PATH and PATH environment variables are correct and that the non-root user has read-access to the Oracle client directories.Caused by: java.lang.UnsatisfiedLinkError: ocijdbc11 (Not found in java.library.path) at java.lang.ClassLoader.loadLibraryWithPath(ClassLoader.java:1035) at java.lang.ClassLoader.loadLibraryWithClassLoader(ClassLoader.java:999)
- The net service name cannot be resolved.If you use a type 4 JDBC driver, you can encounter the following error message if the net service name that you specify is invalid:
You can also encounter the following error message that references a specific Oracle error message code:-jdbcURL jdbc:oracle:thin:@/myhostname:1521/invalid
This code,Caused by: oracle.net.ns.NetException: Listener refused the connection with the following error: ORA-12514, TNS:listener does not currently know of service requested in connect descriptor at oracle.net.ns.NSProtocol.connect(NSProtocol.java:395)
ORA-12514
, returns when the specified service name is unknown. Ensure that you specify the correct net service name and other database parameters when you run a utility or script.If you use a type 4 JDBC driver, you can e
If you use a type 2 JDBC driver, you can encounter the following error message if the net service name that you specify is invalid:
You can also encounter the following error message that references a specific Oracle error message code:-jdbcURL jdbc:oracle:oci:@invalid
This code,java.sql.SQLException: ORA-12154: TNS:could not resolve the connect identifier specified at oracle.jdbc.driver.T2CConnection.checkError(T2CConnection.java:765) at oracle.jdbc.driver.T2CConnection.logon(T2CConnection.java:414)
ORA-12154
, identifies that the error is that the net service name cannot be found in the tnsnames.ora file for your Oracle client. Update the file for your client to include the correct net service name parameters. - The Oracle SID cannot be resolved.If you use a type 4 JDBC driver, you can encounter the following error message if the SID that you specify is invalid:
You can also encounter the following error message that references a specific Oracle error message code,-jdbcURL jdbc:oracle:thin:@myhostname:1521:invalid
ORA-12505
, when the SID that you specify is unknown:
This error can occur when you specify a net service name instead of the SID. Ensure that you include the correct SID and other database parameters when you run a utility or script.Caused by: oracle.net.ns.NetException: Listener refused the connection with the following error: ORA-12505, TNS:listener does not currently know of SID given in connect descriptor at oracle.net.ns.NSProtocol.connect(NSProtocol.java:395) at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1102)
- A database connection cannot be established during instance creation,
feature enablement, or database update.During instance creation, feature enablement, database update with the updatedb utility, or any other Ant tasks, WebSphere Commerce uses the db parameter that is specified when you run a utility to compose a type 2 JDBC URL for connecting to the database. This JDBC URL is formatted to use the SID. If you do not specify the SID, the connection fails and an error message that is similar to the following message can display:
Ensure that you do specify the SID when you run a utility or script that requires an SID formatted JDBC URL to connect to the database.WC_installdir/components/common/xml/enableFeature.xml:89: The following error occurred while executing this line: WC_installdir/components/common/xml/checkPrerequisites.xml:93: java.sql.SQLException: Listener refused the connection with the following error: ORA-12505, TNS:listener does not currently know of SID given in connect descriptor at org.apache.tools.ant.ProjectHelper.addLocationToBuildException(ProjectHelper.java:539) at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:384)
Note: This error is common with Oracle RAC environments when you specify a service name instead of the SID to connect to the database. For more information, see- Using Oracle Real Application Clusters (RAC) with WebSphere Commerce
- Installing and configuring a new Oracle RAC database
- Using Oracle Real Application Clusters (RAC) with WebSphere Commerce
- Installing and configuring a new Oracle RAC database
- di-buildindex utility fails, which is Caused by:
oracle.net.ns.NetException.
Oracle does not support an attribute value that is configured in the wc-data-config.xml. To fix the issue, see Full import failed during di-buildindex utility.