# データベースへの接続

## データベースに接続する方法

&#x20;MariaDBのサンプルスキーマの`ozdemodb` に接続します（[サンプルデータベース](https://jp.ozeform.io/learning/preparation/sample-database) を参照）。

### :ballot\_box\_with\_check: ダイアログを使用

1. テーブルリストで**データベース**を右クリックした後、**データベースの追加**をクリックします。
2. ”データベースの接続情報の追加”ダイアログを表示させます。
3. 以下のように接続情報を入力した後、**OK**をクリックします。

![](/files/-LzkqUL7yBmSUhwLGjgk)

### :ballot\_box\_with\_check: データベースのコネクションプールを利用

#### db.propertiesの準備

以下のパスに複数のデータベースのdb.propertiesのサンプルがあります。`C:\Program Files (x86)\FORCS\OZ Enterprise Server 8.0\OZ Servlet 8.0\WEB-INF\conf\sample\`&#x20;

MariaDBに接続するには、サンプルから`db.properties.mariadb`をコピーした後、ファイル名を`db.properties` に変更して`C:\Program Files (x86)\FORCS\OZ e-Form 8.0\OZ Query Designer 8.0\` 配下に貼り付けます。   &#x20;

その後、エイリアス名、データベース名、サーバーアドレス、ユーザー、パスワードを変更します。

{% code title="db.properties" %}

```
# for mariaDB
# 'demo' will be the Alias name
demo.vendor=mysql
demo.portNo=3306
demo.dbName=ozdemodb
demo.serverAddress=127.0.0.1
demo.user=root
demo.password=password
demo.maxconns=20
demo.initconns=5
demo.timeout=5
demo.initSqls=
demo.closeSqls=
demo.doConnectionCheck=true
demo.testQueryString=select 1
demo.sessionQuery=
demo.encodecharset=
demo.decodecharset=
demo.fetchrow=0
demo.ignoreQueryError=false
```

{% endcode %}

#### データベースに接続

1. データベースの接続情報の追加ダイアログを開きます。
2. **データソース名**に**orderList**と入力した後、**エイリアス**を確認します。
3. **エイリアスファイル**で`db.properties`を選択します。
4. **OK**をクリックします。

### :ballot\_box\_with\_check:データベース情報

1. データベースに接続すると、テーブルリストタブに当該DBのテーブルがリストで表示されます。
2. &#x20;テーブル名を右クリックすると、テーブルフィールド情報またはデータ行が表示できます（デフォルトでは最大100行）。&#x20;
3. 最大行数を変更するには、**ファイル**タブメニューに移動し、**オプション** > **環境** > **一般**を選択します。

![](/files/-LzjrvbPp0BgI3V7s_bo)

## 注

{% hint style="warning" %}

#### Oracle 12cに接続する場合

1. oracle jdbcドライバーのojdbc8.jarファイルを取得し、`"C:\Program Files (x86)\FORCS\OZ e-Form 8.0\OZ Query Designer 8.0\lib\"`に配置します。
2. `″OZ Query Designer 8.0\conf\launch.cfg″`

   ファイルを開き、CLASSPATHパラメーター定義で″`UniversalDriver\classes12.zip″`

   を`"lib\ojdbc8.jar"`に置き換えます。
   {% endhint %}

{% hint style="danger" %}

#### MS SQL Serverへの接続に問題がある場合

1. トップメニューバーで**ファイル**をクリックし、**オプション** >  **環境** > サーバー設定 **> ローカルサーバーのタイプ:** > **.Net**を選択します。&#x20;
2. **.Net**アイテムが表示されない場合は、OZ e-Formパッケージのインストールシールドを実行させ、Setup Type ページ&#x3067;**.NET**オプションにチェックが入っていることを確認します。
   {% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://jp.ozeform.io/report-design-examples/connecting-to-db.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
