Create the data source

A data source maintains a pool of connections to a database server, increasing performance by allowing connection sharing and reuse.

StepsCreating the data source

  1. In the Management Console, expand the Resources folder and locate the JDBC Data Sources folder beneath it. Right-click on JDBC Data Sources folder and choose Add.

  2. In the New Data Source wizard, enter Glossary as the name. Finish the wizard to display the properties for the new Glossary data source.

  3. Configure the properties on the General tab listed in Table 6-3, then click Apply to save the changes. Leave properties that are not listed in Table 6-3 at their default setting.

    NoteBe sure to click Apply to save changes when switching between tabs in property pages.

    The Database Type setting determines the default settings for other data source properties. In this case, setting it to Sybase_ASA (to indicate Sybase Adaptive Server Anywhere) causes EAServer to use Sybase jConnect as the database driver as well as making the default URL format the one used by jConnect. You can define and modify database types to change the default data source property values for that database type.

    Table 6-3: Data source General tab settings

    Setting

    Value

    Database Type

    Sybase_ASA

    Server name

    localhost

    Port Number

    2640

    User name

    dba

    Password

    sql

  4. Configure the Database tab settings listed in Table 6-4 and click Apply. These settings allow EAServer to start and stop the server automatically. Leave settings that are not listed at their default value.

    Table 6-4: Data source Database tab settings

    Setting

    Value

    Database File

    ~/data/gloss.db

    Database Create Command

    Leave blank. This setting can be configured to create a database file for EJB CMP entity beans. We have already created the database file.

    Database Start Command

    asa-start${.bat} -x tcpip(ServerPort=2640) -n ${dataSource} ${databaseFile}

    This command runs asa-start (located in the EAServer bin directory), starting the server to listen on port 2640, with engine name matching the data source name (Glossary), and database file matching the value of the Database File setting (gloss.db).

    Database Stop Command

    asa-stop${.bat} -y -c "uid=dba;pwd=sql;eng=${dataSource}"

    This command runs asa-stop (located in the EAServer bin directory), stopping the server. The command specifies the user name and password required to connect and the engine name.

    Database Command Echo

    Enabled.

    Database Command Destroy on Exit

    Disabled.

  5. Verify the data source properties as follows:

    1. Expand the Data Sources folder.

    2. Right-click the Glossary data source and choose Ping.

      Since the server is starting the database, it will take some time before Ping completes. If the Ping operation fails, confirm that you have applied the settings correctly and that the database is running. You can see the database commands on the server console and in the server log file.