そごうソフトウェア研究所

SOA、開発プロセス、ITアーキテクチャなどについて書いています。Twitterやってます@rsogo

Mule ESB 3.7のDatabase Connectorを試す1(設定とSELECT)

デプロイ

mule-config.xmlをappsの下に作ったdatabaseフォルダに置きます。

$ pwd
/Users/rsogo/work/mule-standalone-3.7.0/apps/database
$ ls
mule-config.xml

gist.github.com

デプロイ時ログ

おぉ、成功。

*******************************************************************************************************
*            - - + APPLICATION + - -            *       - - + DOMAIN + - -       * - - + STATUS + - - *
*******************************************************************************************************
* default                                       * default                        * DEPLOYED           *
* database                                      * default                        * DEPLOYED           *
*******************************************************************************************************

JDBC Driverの配置

  • Database Driverになにもやってない状態でhttp://localhost:8081/にアクセスすると次のようなエラーがでた。
org.mule.module.db.internal.domain.connection.ConnectionCreationException: java.sql.SQLException: Error trying to load driver: oracle.jdbc.Driver : oracle.jdbc.Driver (java.sql.SQLException). Message payload is of type: NullPayload

OracleからJDBC Driverをダウンロードする。

Oracle Database 12c Release 1 JDBC Driver Downloads

自分の環境はJDK1.7を使っているので、ojdbc7.jar

{MULE_HOME}/lib/user/配下に置く。

$ ls lib/user/
README.txt          mule-tests-functional-3.7.0.jar xmlunit-1.5.jar
junit-4.11.jar          ojdbc7.jar

StackOverflowかどこかに{MULE_HOME}/lib/mule/に置けって言っている人がいるけど、それだと動かなかった。

  • DriverはOKで、コネクションが確立できない場合のログ。
org.mule.module.db.internal.domain.connection.ConnectionCreationException: java.sql.SQLException: Cannot get connection for URL jdbc:oracle:thin:{User}/{Password}@localhost:{SID} : No suitable driver found for jdbc:oracle:thin:{User}/{Password}@localhost:{SID} (java.sql.SQLException). Message payload is of type: NullPayload

実行

Muleを実行しているマシンのhttp://locahost:8081/にアクセスしてみる。 上手く行っていると、データベースに検索した結果がJSONに変換されたレスポンスが見られる。

続きを次のエントリで書いています。 begirama.hatenablog.com