Monday, December 13, 2010

Configuring WSO2 BAM to connect to different Databases

Connecting to mySql database.

1. You need to execute the mysql.sql in BAM_HOME/dbscripts folder.

- Navigate to where you have the above script.
- Login to MySQL as the root user.
mysql -u root -p
- give the password at the prompt

- Execute the mysql.sql script.
source mysql.sql


This will create the BAM database. To connect to the database you need to:

2. Copy the mysql driver to CARBON.
- Navigate to BAM_HOME/repository/components/lib and copy mysql-connector-java-5.1.7-bin.jar.

3. Update BAM_HOME/repository/conf/datasources.properties with your database information. A sample is done below.
synapse.datasources=bamMySQL
synapse.datasources.icFactory=com.sun.jndi.rmi.registry.RegistryContextFactory
synapse.datasources.providerPort=2199
synapse.datasources.bamh2.registry=JNDI
synapse.datasources.bamh2.type=BasicDataSource
synapse.datasources.bamh2.driverClassName=com.mysql.jdbc.Driver
synapse.datasources.bamh2.url=jdbc:mysql://localhost:3306/wso2bam_db
synapse.datasources.bamh2.username=wso2bam
synapse.datasources.bamh2.password=wso2bam‎
synapse.datasources.bamh2.dsName=bam_datasource
synapse.datasources.bamh2.maxActive=100
synapse.datasources.bamh2.maxIdle=20
synapse.datasources.bamh2.maxWait=10000

Connecting to Oracle database

1. You need to execute the oracle.sql in BAM_HOME/dbscripts folder.

- Login to SQLPlus as a sysdba and create the db user and grant required access.
$sqlplus sys as sysdba; 

SQL> startup
drop user wso2bam‎ cascade; 
Create user wso2bam‎ identified by wso2bam account unlock; 
grant connect to wso2bam; 
grant create session, dba to wso2bam;
commit;

Now login from the above created user and execute the oracle.sql script

sqlplus wso2bam/wso2bam@10.100.1.10/ORCL
SQL>>@/dbscripts/bam/bam_schema_oracle.sql;

This will create the BAM database. To connect to the database you need to:

2. Copy the mysql driver to CARBON.
- Navigate to BAM_HOME/repository/components/lib and copy ojdbc14.jar.

3. Update BAM_HOME/repository/conf/datasources.properties with your database information. A sample is done below.
synapse.datasources=bamOracle
synapse.datasources.icFactory=com.sun.jndi.rmi.registry.RegistryContextFactory
synapse.datasources.providerPort=2199
synapse.datasources.bamh2.registry=JNDI
synapse.datasources.bamh2.type=BasicDataSource
synapse.datasources.bamh2.driverClassName=oracle.jdbc.driver.OracleDriver
synapse.datasources.bamh2.url=jdbc:oracle:thin:@localhost:1521/wso2bam_db
synapse.datasources.bamh2.username=wso2bam
synapse.datasources.bamh2.password=wso2bam
synapse.datasources.bamh2.dsName=bam_datasource
synapse.datasources.bamh2.maxActive=100
synapse.datasources.bamh2.maxIdle=20
synapse.datasources.bamh2.maxWait=10000

1 comment:

  1. Caused by: javax.xml.stream.XMLStreamException: DS Fault Message: Error in 'SQLQuery.proces
    NormalQuery'
    DS Code: DATABASE_ERROR
    Source Data Service:-
    Name: BAMConfigurationDS
    Location: \BAMConfigurationDS.dbs
    Description: N/A
    Default Namespace: http://ws.wso2.org/dataservice
    Current Request Name: getServersForServerType
    Current Params: {serverType=PullServer}
    Nested Exception:-
    DS Fault Message: The data source is nonexistent
    DS Code: UNKNOWN_ERROR


    at org.wso2.carbon.dataservices.core.engine.DSOMDataSource.execute(DSOMDataSource.j
    va:142)
    at org.wso2.carbon.dataservices.core.engine.DSOMDataSource.prefetchData(DSOMDataSou
    ce.java:86)
    ... 22 more
    [2011-07-12 15:30:18,467] ERROR {org.wso2.carbon.bam.core.collector.DataCollector} - Error
    occurred while retrieving the server list for polling data
    org.wso2.carbon.bam.util.BAMException: Failed to get server details
    at org.wso2.carbon.bam.common.clients.BAMConfigurationDSClient.getServersforServerT
    pe(BAMConfigurationDSClient.java:161)
    at org.wso2.carbon.bam.core.persistence.BAMPersistenceManager.getMonitoredServersBy
    ype(BAMPersistenceManager.java:847)
    at org.wso2.carbon.bam.core.collector.DataCollector.run(DataCollector.java:66)
    at java.util.TimerThread.mainLoop(Timer.java:512)
    at java.util.TimerThread.run(Timer.java:462)
    Caused by: org.wso2.carbon.bam.services.stub.bamconfigurationds.DataServiceFaultException:
    ataServiceFaultException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorI
    pl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorA
    cessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at java.lang.Class.newInstance0(Class.java:355)
    at java.lang.Class.newInstance(Class.java:308)
    at org.wso2.carbon.bam.services.stub.bamconfigurationds.BAMConfigurationDSStub.getS
    rversForServerType(BAMConfigurationDSStub.java:6400)
    at org.wso2.carbon.bam.common.clients.BAMConfigurationDSClient.getServersforServerT
    pe(BAMConfigurationDSClient.java:152)
    ... 4 more

    ReplyDelete

Featured

Selenium - Page Object Model and Action Methods

  How we change this code to PageObjectModel and action classes. 1 2 3 driver . findElement ( By . id ( "userEmail" )). sendKeys (...

Popular Posts