I'm trying to createDatasource on websphere image:websphere-traditional:9.0.5.5-ubi8
I'm trying to create datasource for Postgresql.Here is my code which I execute in postre-datasource.py file:
jdbcProvider = AdminTask.createJDBCProvider(
'[-scope Node=DefaultNode01 -databaseType "User-defined" -providerType "User-defined JDBC Provider" -implementationType "User-defined" -name "Postgres JDBC Provider" -description "PostgreSQL JDBC Driver" -implementationClassName org.postgresql.jdbc3.Jdbc3ConnectionPool -classpath [/opt/postgres/postgresql-42.2.14.jar ] -nativePath "" ]')
print("jdbcProvider: "+jdbcProvider)
datasource = AdminTask.createDatasource(
jdbcProvider, '[-name myname -jndiName jdbc/myjndiName -dataStoreHelperClassName com.ibm.websphere.rsadapter.GenericDataStoreHelper -containerManagedPersistence true -componentManagedAuthenticationAlias DefaultNode01/DB_USER_POSTGRES -xaRecoveryAuthAlias DefaultNode01/DB_USER_POSTGRES -configureResourceProperties [[URL java.lang.String jdbc:postgresql://postgres:5432/postgres]]]')
print("datasource: " + datasource)
m = AdminConfig.create('MappingModule', datasource,
'[[authDataAlias DefaultNode01/DB_USER_POSTGRES] [mappingConfigAlias DefaultPrincipalMapping]]')
print("m: "+m)
AdminConfig.save()
I get an error like:
exception information: com.ibm.ws.scripting.ScriptingException: WASX8018E: Cannot find a match for option value [URL, java.lang.String, jdbc:postgresql://postgres:5432/postgres] for step configureResourceProperties
But when I try it withthe Oracle db with oracle-datasource.py. It sucessfuly run without any error.
jdbcProvider = AdminTask.createJDBCProvider(
'[-scope Node=DefaultNode01 -databaseType Oracle -providerType "Oracle JDBC Driver" -implementationType "XA data source" -name "Oracle JDBC Driver (XA)" -description "Oracle JDBC Driver (XA)" -classpath [/opt/oracle/ojdbc8.jar ] -nativePath "" ]')
print("jdbcProvider: "+jdbcProvider)
datasource = AdminTask.createDatasource(
jdbcProvider, '[-name myname -jndiName jdbc/myjndiName -dataStoreHelperClassName com.ibm.websphere.rsadapter.Oracle11gDataStoreHelper -containerManagedPersistence true -componentManagedAuthenticationAlias DefaultNode01/APPMY_USER -xaRecoveryAuthAlias DefaultNode01/APPMY_USER -configureResourceProperties [[URL java.lang.String jdbc:oracle:thin:@oracle:1521/xepdb1]]]')
print("datasource: " + datasource)
Am I missing something with the Postgresql datasource?
The difference compared to the Oracle Datasource is that for PostgreSQL you're using a user-defined JDBC provider, so you can't leverage the JDBC driver-specific templates providing sets of driver-specific custom properties that are shipped with the WebSphere product.
You can try adding the custom property to your datasource like this:
datasource = # ... create from provider, e.g. as in the question
propSet = AdminConfig.showAttribute(datasource , 'propertySet')
name = ['name', 'URL']
value = ['value', 'jdbc:postgresql://postgres:5432/postgres']
rpAttrs = [name, value]
print AdminConfig.create('J2EEResourceProperty', propSet, rpAttrs)
(This seems to be what this doc is getting at but it doesn't show actually setting a value.)