接続の確立
JDBC データソースの作成
Java アプリケーションから接続するJDBC データソースを作成できます。CData JDBC Driver for EnterpriseDB に基づくJDBC データソースの作成は、3つの基本ステップで構成されます。
- ドライバーのJAR ファイルをクラスパスに追加します。JAR ファイルはインストールディレクトリの[lib]サブフォルダ内にあります。.lic ファイルはJAR ファイルと同じフォルダ内に配置される必要があることに注意してください。
- ドライバークラスを入力します。次に例を示します。
cdata.jdbc.enterprisedb.EnterpriseDBDriver
- JDBC URL を入力します。次に例を示します。
jdbc:enterprisedb:User=postgres;Password=admin;Database=postgres;Server=127.0.0.1;Port=5444 or jdbc:cdata:enterprisedb:User=postgres;Password=admin;Database=postgres;Server=127.0.0.1;Port=5444
上記の2つ目の形式は、同じURL 形式を使用しているドライバー間でアプリケーションに競合がある場合は、CData ドライバーを使用していることを確認するために常に使用できます。URL は "jdbc:enterprisedb:" または"jdbc:cdata:enterprisedb:" のいずれかから始まり、任意の接続プロパティの名前と値のペアをセミコロン区切りで入力します。
Connecting to EnterpriseDB
The following connection properties are required in order to connect to data.
- User: The user which will be used to authenticate with the EnterpriseDB server.
- Password: The password which will be used to authenticate with the EnterpriseDB server.
- Server: The host name or IP of the server hosting the EnterpriseDB database.
- Port: The port of the server hosting the EnterpriseDB database.
You can also optionally set the following:
- Database: The default database to connect to when connecting to the EnterpriseDB Server. If this is not set, the user's default database will be used.