Follow the instructions below to set up the MS SQL database.The following sections describe how to replace the default H2 database with MS SQL:
Table of Contents maxLevel 3
Setup Database and User
Enable TCP/IP
1. Open "SQL Server Configuration Manager" from Start Programs Microsoft SQL Server 2005 Configuration Tools SQL Server Configuration Manager.
2. Enable "TCP/IP" and disable "Named Pipes" from protocols of your MSSQL server.
3. Open TCP/IP Properties by double clicking "TCP/IP." Set "Listen All" to "Yes" in the "Protocol" tab.
4. From the "IP Address" tab, disable "TCP Dynamic Ports" by leaving it blank and give a valid "TCP Port" so that MSSQL server will listen in that port.
Info | ||
---|---|---|
| ||
You can use port 1433 in order processor services, so it is better to use that port. |
5. Similarly, enable TCP/IP from "SQL Native Client Configuration" and disable "Named Pipes." Also, check whether the port is set correctly. Port should be 1433.
6. Restart MSSQL Server.
Create Database and User
1. Open "MSSQL Management Studio" to create a database and user.
2. Go to Database New Database and specify all the options to create a new database.
3. Go to Logins New Login and specify all the necessary options.
Grant Permission
Give required grants/permission to newly created user. Grant should allow newly created user to login, create tables, insert data to tables in newly created database.
Setup Configuration File
1. Edit the default database configuration defined in the master-datasources.xml
file located at <PRODUCT_HOME>/repository/conf/datasources
directory as below. Both the database configurations in registry.xml
and user-mgt.xml
refer this data source.
Info |
---|
You have to replace these settings with your custom values. |
Code Block | ||
---|---|---|
| ||
<datasource>
<name>WSO2_CARBON_DB</name>
<description>The datasource used for registry and user manager</description>
<jndiConfig>
<name>jdbc/WSO2CarbonDB</name>
</jndiConfig>
<definition type="RDBMS">
<configuration>
<url>jdbc:jtds:sqlserver://10.100.3.251:1433/wso2greg</url>
<userName>regadmin</userName>
<password>regadmin</password>
<driverClassName>net.sourceforge.jtds.jdbc.Driver</driverClassName>
<maxActive>80</maxActive>
<maxWait>60000</maxWait>
<minIdle>5</minIdle>
<testOnBorrow>true</testOnBorrow>
<validationQuery>SELECT 1</validationQuery>
<validationInterval>30000</validationInterval>
</configuration>
</definition>
</datasource> |
The database configuration options
- url - The URL of the database.
- username - The name of the database user.
- password - The password of the database user.
- driverClassName - The class name of the database driver.
- maxActive - The maximum number of active connections that can be allocated from this pool at the same time or negative for no limit.
- maxWait - The maximum number of milliseconds that the pool will wait (when there are no available connections) for a connection to be returned before throwing an exception, or <= 0 to wait indefinitely.
- minIdle - The minimum number of active connections that can remain idle in the pool without extra ones being created or 0 to create none.
Info | ||
---|---|---|
| ||
Default port for MSSQL is 1433. |
Copy JDBC Driver
Copy MSSQL JDBC driver jtds-1.2.2.jar
to <PRODUCT_HOME>/repository/components/lib
.
Info | ||
---|---|---|
| ||
JDBC driver can be downloaded from http://sourceforge.net/projects/jtds/files/ |
Create Database Tables
Database tables can be created either manually by running scripts or automatically by using start-up parameters.
- Using Scripts
Database tables can be created manually by logging in to created database and running <PRODUCT_HOME>/dbscripts/mssql.sql
.
- Using start-up Parameters
Windows users can run <PRODUCT_HOME>/bin/wso2server.bat -Dsetup
to create the database tables when starting the product for the first time.
Linux users should use <PRODUCT_HOME>/bin/wso2server.sh -Dsetup
. Include Page shared:Setting up Microsoft SQL (V1) shared:Setting up Microsoft SQL (V1)
Changing the identity database
The topics above show how to change the WSO2_CARBON_DB
, which is used to store registry and user manager information. If you set up a separate database for identity related data, the instructions are the same. In summary:
Add the datasource to the
master-datasources.xml
file.Create the database tables using the following scripts:
For the identity database Use
<PRODUCT_HOME>/dbscripts/identity/mssql.sql