Access H2 Embedded Database for WSO2 products - wso2

I am using stream processor 4.3.0 and need to access the H2 Database for it which comes by default in WSO2 SP application.
Can some please help me here to access/browse the database.
Thanks

And need to access the H2 Database for it which comes by default in WSO2 SP application
For WSO2SP DB configuration stored in:
${carbon.home}/conf/worker/deploymment.yaml
${carbon.home}/conf/dashboard/deploymment.yaml
${carbon.home}/conf/..other module../deploymment.yaml
so you can check the database locations
by default check
${carbon.home}/wso2/worker/database
${carbon.home}/wso2/dashboard/database
${carbon.home}/wso2/..other module../database
You can use H2 Shell to access the databases
Please note the embedded H2 databases are not intended to be accessed from multiple processes concurrently, so stop the wso2sp first

please find the answer below.
Open the /repository/conf/carbon.xml file and paste the following configuration.
Do not uncomment the existing element. Just paste the following configuration below it.
<H2DatabaseConfiguration>
<property name="web"/>
<property name="webPort">8082</property>
<property name="webAllowOthers"/>
</H2DatabaseConfiguration>
3.Restart the WSO2 product and access the following URL via your browser: http://localhost:8082
Tip: If you are logged in to the management console, log out before connecting to the database.
4.Enter the following details and click Connect.
JDBC URL : jdbc:h2:[file path to /repository/database/WSO2CARBON_DB]
username : wso2carbon
password : wso2carbon

Related

How Can I Setup a Google CloudSQL user that can connect only from App Engine Standard Environment

I have a Java JSP application that uses JPA to connect to CloudSQL. The issue I am facing is that I am failing to setup a CloudSQL user that will be allowed access only from App Engine. Even after setting the user up to connect only via CloudSQL proxy it still fails. The user can only access the db when I put in the whitelist all IP.
I finally managed to get it working. The issue was that I was using the wrong jdbc driver. To enable my desired requirement I had to configure a cloudsqlproxy user and use the below connection string and driver to get it to work in App Engine:
<property name="javax.persistence.jdbc.url" value="jdbc:google:mysql://instance-name/database"/>
<property name="javax.persistence.jdbc.user" value="user"/>
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.GoogleDriver"/>
NB: The above only works after deployment to App Engine. You can use the standard non-Google jdbc driver to test on your local machine

Cannot browse the h2 database from a web browser in WSO2 api manager

I am trying to browse local H2 db for WSO2 api manager. I made the change in the WSO2_HOME/repository/conf/carbon.xml. I added below configuration.
<H2DatabaseConfiguration>
<property name="web"/>
<property name="webPort">8082</property>
<property name="webAllowOthers"/>
</H2DatabaseConfiguration>
After I restart WSO2 api server the change in the file WSO2_HOME/repository/conf/carbon.xml gets lost. As a result I am not able to connect to H2 db. I am working on version WSO2 3.0.0.
In WSO2 APIM 3.0.0, the configuration model is different. You need to add the following to ../repository/conf/deployment.toml
[database_configuration]
enable_h2_console = true
Ref: https://apim.docs.wso2.com/en/latest/Reference/ConfigCatalog/#enabling-the-h2-database-console
In addition to Bee's answer it is important to mention that we also need to provide proper jdbc URL for that
copy the location of the <API_Manager_home>/repository/database/[databaseName] (here do not copy .mv part i.e extension part)
for me the JDBC URL was jdbc:h2:/Users/akshay/code/w/98/98_base_1/repository/database/WSO2AM_DB
default username and password is wso2carbon/wso2carbon

wso2 identity server with postgres database schema

Actually I want to setup wso2is 5.3.0 with the postgres schema for production environment, which I have configured as "jdbc:postgresql://localhost:5432/wso2?currentSchema=wso2pgschema" in the masterdatasources.xml file and able to install wso2is in the postgres schema but when I goes to the browser and tries to login its gives me error
[LOG]
[2017-05-14 19:15:59,023] ERROR {org.wso2.carbon.user.core.common.AbstractUserStoreManager} - Error occurred while accessing Java Security Manager Privilege Block
[2017-05-14 19:15:59,026] ERROR {org.wso2.carbon.core.services.authentication.AuthenticationAdmin} - System error while Authenticating/Authorizing User : Error when handling event : PRE_AUTHENTICATION
Is there a way we can install it database schema ?or we have to install it in the database public schema/keep installation with the inbuild h2 database for production.
Please Help.
Thanks
Pankaj
Yes, you can use a schema other than the public schema. Please refer the post here for the steps.
For the second part of the question, the default H2 database is not recommended for production systems.

Using placeholders in WSO2 DSS dbs files for DB connection params

Is it possible to use placeholders in WSO2 DSS db connection params - e.g. ${prod.db.url} and replace them in runtime from Registry?
Thanks.
The datasource connection is checked and established in the dataservice deployment time. Therefore, you have to provide the datasource configurations such as driver class name, connection url. etc. at the deployment time.
Since the datasource configurations like db url, driver name, user name, password is needed during deployment stage, its not possible to refer the same from registry.
I assume your requirement comes from the need to manage different environments, to achieve the same, have the option to create datasources at server level, called Carbon_Datasources.
These datasources can be referred from .dbs file like the below one. In the below example, serviceDS is the datasource configured.
<config id="rs">
<property name="carbon_datasource_name">serviceDS</property>
</config>
<query id="deliveryService" useConfig="rs">
Refer here for adding different types of datasources and here for managing the same.

WSO2 identity server external JDBC store

I want to use a external JDBC store as default store instead of the default LDAP store. Followed the documentation in this link.
http://docs.wso2.org/wiki/display/IS400/Configuring+an+External+JDBC+User+Store
Getting the following exception Appreciate any help.
An unknown exception occurred while starting LDAP server.java.lang.NullPointerException: Name is null
You can configure WSO2 IS 4.0.0 with an external JDBC users store.The problem is due to an issue with the instructions in the documentation(1) as some configuration steps are missing there.I have created the jira [DOCUMENTATION-17] to track this doc issue.
Please follow below steps to connect IS 4.0.0 with external jdbc users-store.
1) Change the UserStoreManager class to JDBCUserStoreManager from user-mgt.xml [IS_Home/repository/conf] and add the related database connection property to it as mentioned in (1)
2) Add 'passwordHashMethod' propert within JDBCUserStoreManager and set the value to 'SHA' or 'PLAIN_TEXT' in {IS_HOME}/repository/conf/user-mgt.xml.
Eg: <Property name="passwordHashMethod">SHA</Property>
3) Set value of the 'MultiTenantRealmConfigBuilder' property to 'org.wso2.carbon.user.core.config.multitenancy.SimpleRealmConfigBuilder' in {IS_HOME}/repository/conf/user-mgt.xml.
Eg: <Property name="MultiTenantRealmConfigBuilder">org.wso2.carbon.user.core.config.multitenancy.SimpleRealmConfigBuilder</Property>
4) Enable JDBCTenantManager in tenant-mgt.xml and comment out the config section for CommonHybridLDAPTenantManager.
Once you did above configurations,you'll able to configure WSO2 Identity Server to an external jdbc user store successfully.
(1) http://docs.wso2.org/wiki/display/IS400/Configuring+an+External+JDBC+User+Store
I was able to resolve this.
Start with a clean install of WSO2 IS 4.0.0 if possible.
Apart from following the directions given in the documentation to setup a JDBC datastore; you need to do the following :
Enable JDBCTenantManager in tenant-mgt.xml and comment out CommonHybridLDAPTenantManager2
Set the enable property to false for EmbeddedLDAP in embedded-ldap.xml