<LearnWLS> Setting Up Examples to Run with a Derby Database

本文介绍如何配置Derby数据库以供Oracle WebLogic Server使用,包括生成Derby数据、设置连接属性及配置JDBC数据源等步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

The examples installed with Oracle WebLogic Server include the Derby "examples" database. The wl_server examples domain includes JDBC data sources configured to use with the Derby database out-of-the-box. You do not need to configure the database or database connectivity when running the examples in the wl_server domain. For more information about Derby, see the public ApacheDerby documentation. The information in the following sections can help you configure database connectivity if you want to run the examples from a different domain or if you want to recreate the data in the database.

Prerequisites

Make sure that the Derby server is running and that you have the following information:

  • Database name

  • Host name or IP address

  • Port

  • Database username and password

Derby starts automatically when the examples Server in the wl_server domain is started. Make sure that the Derby server is running. Use the Derby "ij" tool located in the WL_HOME\common\derby\bin subdirectory of the WebLogic Server installation directory. If you are running the examples in a different domain, you can manually start the Derby server. See Starting Derby.

Generating Derby Data

Follow these steps to configure Oracle WebLogic Server exampleproperty values and populate the Derby database with sample data:

  1. Using a text editor, open the examples.properties file, located inthe EXAMPLES_HOME\examples\src directory, where EXAMPLES_HOME represents the root directory in which the WebLogic Server Examples are configured; for example: C:\Oracle\Middleware\Oracle_Home\wlserver\samples\server.

  2. Change the following lines to fit your environment:

    • derby.url=jdbc:derby://localhost:1527/examples;create=true;ServerName=localhost;databaseName=examples

    • derby.username=examples

    • derby.password=examples

    Save the file when you are finished.

  3. Open a command shell and setup the environment.

  4. Change to the EXAMPLES_HOME\examples\src\examples\common\ddl directory.

  5. Enter the following command:

    ant db.setup.derby

    This Ant target creates the tables and inserts sample data.

    To use a database server other than Derby, Oracle, or MySQL, create a db.setup.db_vendor target in the build.xml file, similar to db.setup.derby, and set the driver class; URL; and host, username, and password for the server.

Configuring JDBC Data Sources for Derby

Some Oracle WebLogic Server examples use database connections from JDBC data sources configured in the wl_server domain installed with the Oracle WebLogic Server examples. If you want to run an example in a different domain, you may need add one or more of the data sources to your WebLogic domain.

To configure the examples-demo data source:

  1. Open the Oracle WebLogic Server Administration Console.

  2. In the Domain Structure view in the left pane, expand Services > Data Sources.

  3. On the Summary of JDBC Data Sources page, click New.

  4. On the JDBC Data Source Properties page,enter or select the following information:

    Name - Enter examples-demo.

    JNDI Name - Enter examples-dataSource-demoPool.

    Database Type - Select Derby or the DBMS of the database to which you want to connect. If your DBMS is notlisted, select Other.

    Click Next to continue.

    Database Driver - Select Derby's Driver (Type 4)Versions: Any or another non-XA JDBC driver that you want to use to connect to the database.

    Note: You must install JDBC drivers before you can use them to create database connections. Some JDBC drivers are installed with Oracle WebLogic Server, but not all listed drivers are installed. The Derby driver is installed with Oracle WebLogic Server.

    Click Next to continue.

  5. On the Transactions Options page, follow these steps:

    1. Select Supports Global Transactions.

    2. Select One-Phase Commit.

    Click Next to continue.

  6. On the Connection Properties page, enter values for the following properties:

    Database Name - Enter demo or the name of the database to which you want to connect.

    Host Name - Enter localhost or the DNS name or IP address of the server that hosts the database.

    Port - Enter 1527 for Derby or enter the port on which the database server listens for connections requests.

    Database User Name - Enter examples for the Derby database installed with the Oracle WebLogic Server examples or if you are using a different database, enter the database user account name that you want to use for each connection in the data source.

    Password / Confirm Password - Enter examples for the Derby database or enter the password for the database user acccount specified above.

    Click Next to continue.

  7. On the Test Database Connection page,review the connection parameters and click Test Configuration.

    Oracle WebLogic Server attempts to create a connection from the Administration Server to the database. Results from the connection test are displayed at the top of the page. If the test is unsuccessful, you should correct any configuation errors and retry the test.

    If the JDBC driver you selected is not installed on the Administration Server, you should click Next to skip this step.

    Click Next to continue.

  8. On the Select Targets page, select examples Server or select the servers or clusters on which you want to deploy the data source.

  9. Click Finish to save the JDBC data source configuration. When your changes are activated, the data source will be deployed to the targets that you selected.

  10. To activate these changes, you must restart the server.

To configure the examples-demoXA data source:

  1. Open the Administration Console.

  2. In the Domain Structure view in the left pane, expand Services > Data Sources.

  3. On the Summary of Data Sources page, click New.

  4. On the JDBC Data Source Properties page,enter or select the following information:

    Name - Enter examples-demoXA.

    JNDI Name - Enter examples-dataSource-demoXAPool.

    Database Type - Select Derby or the DBMS of the database to which you want to connect. If your DBMS is notlisted, select Other.

    Click Next to continue.

    Database Driver - Select Derby's Driver (Type 4XA) Versions: Any or another XA JDBC driver that you want to use to connect to the database.

    Note: You must install JDBC drivers before you can use them to create database connections. Some JDBC drivers are installed with Oracle WebLogic Server, but not all listed drivers are installed. The Derby driver is installed with Oracle WebLogic Server.

    Click Next to continue.

  5. On the Transactions Options page, disable Supports Global Transactions.If the XA JDBC driver you selected requires a global transaction to execute SQL code, skip this step. Click Next to continue.

  6. On the Connection Properties page, enter values for the following properties:

    Database Name - Enter demo or the name of the database to which you want to connect.

    Host Name - Enter localhost or the DNS name or IP address of the server that hosts the database.

    Port - Enter 1527 for Derby or enter the port on which the database server listens for connections requests.

    Database User Name - Enter examples for the Derby database installed with the Oracle WebLogic Server examples or if you are using a different database, enter the database user account name that you want to use for each connection in the data source.

    Password/Confirm Password - Enter examples for the Derby database or enter the password for the database user acccount specified above.

    Click Next to continue.

  7. On the Test Database Connection page,review the connection parameters and click Test Configuration.

    Oracle WebLogic Server attempts to create a connection from the Administration Server to the database. Results from the connection test are displayed at the top of the page. If the test is unsuccessful, you should correct any configuation errors and retry the test.

    If the JDBC driver you selected is not installed on the Administration Server, you should click Next to skip this step.

    Click Next to continue.

  8. On the Select Targets page, select examples Server or select the serversor clusters on which you want to deploy the data source.

  9. Click Finish to save the JDBC data source configuration. When your changes are activated, the data source will be deployed to the targets that you selected.

  10. To activate these changes, you must restart the server.

To configure the examples-demoXA-2 data source:

  1. Open the Administration Console.

  2. In the Domain Structure view in the left pane, expand Services > Data Sources.

  3. On the Summary of Data Sources page, click New.

  4. On the JDBC Data Source Properties page,enter or select the following information:

    Name - Enter examples-demoXA-2.

    JNDI Name - Enter examples-demoXA-2.

    Database Type - Select Derby or the DBMS of the database to which you want to connect. If your DBMS is not listed, select Other.

    Click Next to continue.

    Database Driver - Select Derby's Driver (Type 4XA) Versions: Any or another XA JDBC driver that you want to use to connect to the database.

    Note: You must install JDBC drivers before you can use them to create database connections. Some JDBC drivers are installed with Oracle WebLogic Server, but not all listed drivers are installed. The Derby driver is installed with Oracle WebLogic Server.

    Click Next to continue.

  5. On the Transactions Options page, disable Supports Global Transactions.If the XA JDBC driver you selected requires a global transaction to execute SQL code, skip this step. Click Next to continue.

  6. On the Connection Properties page, enter values for the following properties:

    Database Name - Enter demo or the name of the database to which you want to connect.

    Host Name - Enter localhost or the DNS name or IP address of the server that hosts the database.

    Port - Enter 1527 for Derby or enter the port on which the database server listens for connections requests.

    Database User Name - Enter examples for the Derby database installed with the Oracle WebLogic Server examples or if you are using a different database, enter the database user account name that you want to use for each connectionin the data source.

    Password/Confirm Password - Enter examples for the Derby database or enter the password for the database user account specified above.

    Click Next to continue.

  7. On the Test Database Connection page,review the connection parameters and click Test Configuration.

    Oracle WebLogic Server attempts to create a connection from the Administration Server to the database. Results from the connection test are displayed at the top of the page. If the test is unsuccessful, you should correct any configuation errors and retry the test.

    If the JDBC driver you selected is not installed on the Administration Server, you should click Next to skip thisstep.

    Click Next to continue.

  8. On the Select Targets page, select examples Server or select the servers or clusters on which you want to deploy the data source.

  9. Click Finish to save the JDBC data source configuration. When your changes are activated, the data source will be deployed to the targets that you selected.

  10. To activate these changes, you must restart the server.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值