You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@karaf.apache.org by "Paul Spencer (Jira)" <ji...@apache.org> on 2022/04/30 16:38:00 UTC
[jira] [Created] (KARAF-7430) Example of updating a JDBC datasource configuration using Karaf commands.
Paul Spencer created KARAF-7430:
-----------------------------------
Summary: Example of updating a JDBC datasource configuration using Karaf commands.
Key: KARAF-7430
URL: https://issues.apache.org/jira/browse/KARAF-7430
Project: Karaf
Issue Type: Documentation
Components: karaf
Affects Versions: 4.3.6
Reporter: Paul Spencer
The example below demonstrates how to update the configuration of a JDBC datasource using Karaf commands. I was unable to find a concise procedure in the Karaf documentation and wanted to document a procedure for myself and others.
1) Create the datasource "myDb", in this case with an incorrect username of "foo" using the "jdbc:ds-create ..." command
karaf@root()> jdbc:ds-create -dn hsqldb -url "dbc:hsqldb:mem:." -u foo -p bar myDb
2) List the datasource showing the new datasource has an "invalid authorization" status using the "jdbc:ds-list" command
karaf@root()> jdbc:ds-list
Name │ Service Id │ Product │ Version │ URL │ Status
──────────────────┼────────────┼──────────────────────┼──────────────────────────┼─────────────────────────────────────────────────────┼─────────────────────────────────────────────────────
178 │ │ │ │ │ Error invalid authorization specification - not found: foo
3) Identify the Pid for the datasource "myDb" using the "config:list '(service.factoryPid=org.ops4j.datasource)'" command
karaf@root()> config:list '(service.factoryPid=org.ops4j.datasource)'
----------------------------------------------------------------
Pid: org.ops4j.datasource.40c82a9b-e74a-4e8b-86a6-676ffed33b0e
FactoryPid: org.ops4j.datasource
BundleLocation: mvn:org.ops4j.pax.jdbc/pax-jdbc-config/1.5.0
Properties:
dataSourceName = myDb
osgi.jdbc.driver.name = hsqldb
password = bar
service.factoryPid = org.ops4j.datasource
service.pid = org.ops4j.datasource.40c82a9b-e74a-4e8b-86a6-676ffed33b0e
url = dbc:hsqldb:mem:.
user = foo
4) Open and list properties for the datasource "myDb" using the "config:edit org.ops4j.datasource.<Pid>" command, where <Pid> is from above for the dataSourceName myDb
karaf@root()> config:edit org.ops4j.datasource.40c82a9b-e74a-4e8b-86a6-676ffed33b0e
karaf@root()> config:property-list
dataSourceName = myDb
osgi.jdbc.driver.name = hsqldb
password = bar
url = dbc:hsqldb:mem:.
user = foo
5) Make the configuration changes, in this case setting the user to "sa" and removing the password, using the config:property-... commands
karaf@root()> config:property-set user sa
karaf@root()> config:property-delete password
karaf@root()> config:property-list
dataSourceName = myDbAsFoo
osgi.jdbc.driver.name = hsqldb
url = dbc:hsqldb:mem:.
user = sa
6) Save the the configuration changes using the "config:update" command
karaf@root()> config:update
7) List the datasources, showing a correctly configured "myDb"
karaf@root()> jdbc:ds-list
Name │ Service Id │ Product │ Version │ URL │ Status
──────────────────┼────────────┼──────────────────────┼──────────────────────────┼─────────────────────────────────────────────────────┼───────
myDb │ 179 │ HSQL Database Engine │ 2.5.1 │ jdbc:hsqldb:dbc:hsqldb:mem:. │ OK
karaf@root()>
--
This message was sent by Atlassian Jira
(v8.20.7#820007)