This resource tests a database connection. It is typically used to verify the parameters that will be used to create a new data source.
The resource supports the following methods:
The OPTIONS method on this resource returns a template entity that has been pre-populated with default values.
If you want to test a database connection, call this method to get the template, fill in values, such as the driver class name and connection URL, then use it in the POST method to test the connection.
The response body returned includes a DatabaseDriverAttributes entity.
This method returns one of the Standard HTTP Status Codes.
The POST method on this resource converts a set of driver-specific attributes into a generic database connection entity, properly formatting the connection URL and list of properties.
NOTE: Since REST resources are not allowed to return cleartext passwords, the returned driver does not have its password filled in, even though one of the driver attributes holds the password. To compensate for this, the client should hold on to the database driver attributes entity, use its passwordAttributeName
property to find the attribute that holds the password, then set the password
property on the returned database connection entity to that password.
The request body must include a fully populated DatabaseDriverAttributes entity. Read only parameter values are ignored.
The response body returned includes a DatabaseConnection entity.
This method returns one of the Standard HTTP Status Codes.
This example uses the POST method to test a database connection configuration.
Example Request
curl -v \ --user username:password \ -H X-Requested-By:MyClient \ -H Accept:application/json \ -H Content-Type:application/json \ -d "{ url: 'jdbc:derby://localhost:1527/demo', driverName: 'org.apache.derby.jdbc.ClientXADataSource', password: null, properties: [ { name: 'portNumber', value: '1527' }, { name: 'databaseName', value: 'demo;create=true' }, { name: 'serverName', value: 'localhost' } ] }" \ -X POST http://localhost:7001/management/wls/latest/datasources/test
Example Response
HTTP/1.1 200 OK Response Body: {"item": { "cause": [], "ok": true }}