CData JDBC Drivers は標準JDBC インターフェースをサポートし、JVM 上で実行されるWeb アプリケーションに統合します。この記事では、Tomcat のConnection Pool からEDGAR Online に接続する方法について詳しく説明します。
Tomcat のConnection Pool 経由でEDGAR Online データに接続
- CData JAR およびCData .lic ファイルを$CATALINA_HOME/lib にコピーします。CData JAR はインストールディレクトリの[lib]サブフォルダ内にあります。
- コンテキストにリソースの定義を追加します:
- Navigate to https://developer.edgar-online.com/ and create an account.
- Register a new application and retrieve the AppKey. You should select one of the available Web APIs this application will use like HackPack, Insider Trades or Institutional Ownership.
Note: HackPack is the most important Web API that an application can use since it supports a large number of endpoints. If you are getting the "Access Denied" error you must create a new app and select the correct Web API which supports the resource you are querying.
- After successfully creating a new app, you can access your keys through your "my account" area. Set the AppKey connection property value equal to the Key of your application.
<Resource name="jdbc/edgaronline" auth="Container" type="javax.sql.DataSource" driverClassName="cdata.jdbc.edgaronline.EdgarOnlineDriver" factory="org.apache.tomcat.jdbc.pool.DataSourceFactory" url="jdbc:edgaronline:AppKey=20dd8ce9904d422ed89ebde1ad40d" maxActive="20" maxIdle="10" maxWait="-1" />
一つのアプリケーションからEDGAR Online へのアクセスを許可するには、上のコードをアプリケーションのMETA-INF ディレクトリにあるcontext.xml に追加します。
共有リソースの設定には、上のコードを$CATALINA_BASE/conf 内にあるcontext.xml に追加します。共有リソースの設定は、すべてのアプリケーションにSalesforce への接続を提供します。
- アプリケーションのweb.xml にリソースへの参照を追加します。
EDGAR Online data JSP
jdbc/EdgarOnline
javax.sql.DataSource
コンテナ
-
Connection pool からの接続の初期化:
Context initContext = new InitialContext();
Context envContext = (Context)initContext.lookup("java:/comp/env");
DataSource ds = (DataSource)envContext.lookup("jdbc/EdgarOnline");
Connection conn = ds.getConnection();
そのほかのTomcat へのデータ連携ドライバーの統合
上記の手順では、簡単なコネクションプーリングのシナリオでEDGAR Online に接続する方法を説明しました。ほかの使用例や情報については、 Tomcat 製品ドキュメントの 「JNDI Datasource How-To」をご覧ください。