Setting up data source for JBoss

Setting up data source for WildFly and JBoss EAP

Data source configuration in WildFly 10 and JBoss EAP 6.x is almost the same. Here we take WildFly as am example to show you how to create the data source. You can find more details in the corresponding JBoss Web sites: Datasource configuration for WildFly, and Datasource management for JBoss EAP 6.4.

The following section will take one database type (SQL Anywhere database with SAP jConnect JDBC driver) as an example to show you how to create a data source for WildFly, you can later create data sources for other database types by taking the same steps below but specifying different parameters according to Data source parameters.

You need to perform two main tasks to define a data source in WildFly and JBoss EAP. First, you must make the JDBC driver available to the application server; then you need to configure the data source that references the driver you installed.

Installing the JDBC driver

You can install a JDBC driver with the management console or as a Core Module. In this example, we will take the management console approach as an example. If you want to use the Core Module approach, you may refer to the corresponding JBoss documentation.

Step 1: Modify the JAR file of the JDBC driver. Take SAP jConnect JDBC driver as an example.

  1. Under the same directory as the jconn3.jar file, create a "META-INF" subdirectory and a "META-INF\services" subdirectory.

  2. Under the "META-INF\services" directory, create a java.sql.Driver file which contains one line - the fully-qualified class name of the JDBC driver, in this example, com.sybase.jdbc3.jdbc.SybDriver.

  3. Execute the "jar" command to update the JAR file: "jar -uf jconn3.jar META-INF/services/java.sql.Driver". You can also use WinRAR tool to add the META-INF\services\java.sql.Driver directory and file to jconn3.jar, as shown in the following figure.

    Figure 43. Modify the JAR file

    Modify the JAR file

Step 2: Deploy the modified JAR file.

  1. Log into the WildFly management console.

  2. Click Start for Deploy an Application on the home page.

    Figure 44. Start to deploy the JAR file

    Start to deploy the JAR file

  3. Click the Add button on the deployment page. The New Deployment wizard starts.

    Figure 45. Add the JAR file

    Add the JAR file

  4. In the New Deployment Wizard, keep the default option "Upload a new deployment" and click Next.

    Figure 46. New Deployment wizard

    New Deployment wizard

  5. Click Browse to select the modified JAR file and click Next.

    Figure 47. New Deployment wizard

    New Deployment wizard

  6. Verify the deployment settings for the JAR file and click Finish.

    Figure 48. New Deployment wizard

    New Deployment wizard

  7. When deployment is successful, you will be able to see the message "jconn3.jar deployed successfully" and jconn3.jar listed on the deployment page.

Step 3: Wait a few minutes for the JAR file to be detected and listed in the driver list by WildFly or restart WildFly application server to make the JAR file detected and listed immediately.

Configuring the data source

You can configure a data source with the management console or the configuration file. In this example, we will take the management console approach as an example. If you want to use the configuration file approach, you may refer to the corresponding JBoss documentation.

Step 1: On the home page of WildFly management console, click Start for Create a Datasource.

Figure 49. Start to create a new data source

Start to create a new data source


Step 2: On the Configuration page, select Subsystems > Datasources > Non-XA, and then click Add.

Figure 50. Start to create a new data source

Start to create a new data source

Step 3: The Create Datasource wizard starts to guide you through creating a data source.

  1. Select the data source type. In this example, select Sybase Datasource and click Next.

    Figure 51. Select the data source type

    Select the data source type

  2. Input any text as the data source name and the JNDI name. For example, "java:/appeonsample". Click Next.

    Note: The JNDI name will be used as the data source name in AEM.

    Figure 52. Specify the data source attributes

    Specify the data source attributes

  3. Click Detected Driver, and then select the JDBC driver, in this example, jconn3.jar. Click Next.

    If you do not see the driver, make sure you have installed the driver by following instructions in Installing the JDBC driver.

    Figure 53. Specify the JDBC driver

    Specify the JDBC driver

  4. Specify the connection information and click Next.

    The following table describes how to specify the connection information for SAP SQL Anywhere databases. The values are different according to database types. You can refer to Data source parameters.

    Table 23. Connection properties

    Connection URL

    For example, jdbc:sybase:Tds:192.0.3.150:2638/appeonsample

    Username

    Type the database login username. The username is set on the database server.

    Password

    Type the database login password. The password is set on the database server.


    Figure 54. Specify the connection information

    Specify the connection information


  5. Click Test Connection to make sure the database can be connected and then click Finish.

    Figure 55. Test the database connection

    Test the database connection

After the data source is created successfully, you will return to the data source page and you will be able to see the new data source in the list.

Figure 56. Data source list

Data source list

In JBoss EAP, you may need to manually enable the newly created data source by clicking the Enable button on top of the list.

Figure 57. Enable the data source

Enable the data source