本記事では CData サポート担当からこんなことを聞かれたらどこを確認すべきか?という観点で、よく頂くお問合せ内容をご紹介します。
記事はこちら →CData JDBC Driver for ShipStation は、Java Web アプリケーションに簡単に統合して利用することができます。本記事では、Jetty でドライバーをコネクションプールとして設定することで、効率的にShipStation データをアプリケーションで連携利用する方法を説明します。Jetty でJNDI resource for ShipStation を設定します。
次の手順で、Jetty とShipStation の接続を確立します。
Jetty ベースでJNDI モジュールを有効化します。JNDI を有効化するコマンドラインは以下の通り:
java -jar ../start.jar --add-to-startd=jndi
<Configure id='shipstationdemo' class="org.eclipse.jetty.webapp.WebAppContext">
<New id="shipstationdemo" class="org.eclipse.jetty.plus.jndi.Resource">
<Arg><Ref refid="shipstationdemo"/></Arg>
<Arg>jdbc/shipstationdb</Arg>
<Arg>
<New class="cdata.jdbc.shipstation.ShipStationDriver">
<Set name="url">jdbc:shipstation:</Set>
<Set name="APIKey">'YourAPIKey'</Set>
<Set name="APISecret">'YourAPISecret'</Set>
</New>
</Arg>
</New>
</Configure>
Use the BASIC Authentication standard to connect.
Web xml でリソースを設定します:
jdbc/shipstationdb
javax.sql.DataSource
Container
これで、java:comp/env/jdbc/shipstationdb へのルックアップでShipStation データにアクセスできます:
InitialContext ctx = new InitialContext();
DataSource myshipstation = (DataSource)ctx.lookup("java:comp/env/jdbc/shipstationdb");
ここでは、シンプルなコネクションプーリングシナリオでのドライバーの接続について説明しました。追加での連携ケースについては、Jetty ドキュメントのWorking with Jetty JNDI 参照してください。