「SCWCD 準備」の版間の差分
ナビゲーションに移動
検索に移動
| 7行目: | 7行目: | ||
=====Document===== | =====Document===== | ||
*http://java.sun.com/j2ee/1.4/docs/api/index.html | *http://java.sun.com/j2ee/1.4/docs/api/index.html | ||
| − | =====XML Schemas for J2EE Deployment Descriptors===== | + | =====XML Schemas for [[J2EE]] Deployment Descriptors===== |
http://java.sun.com/xml/ns/j2ee/ | http://java.sun.com/xml/ns/j2ee/ | ||
====TOMCAT==== | ====TOMCAT==== | ||
| 17行目: | 17行目: | ||
*準備 | *準備 | ||
**$CATALINA_HOME/common/lib にJDBCドライバを置く | **$CATALINA_HOME/common/lib にJDBCドライバを置く | ||
| − | ** | + | **[[Tomcat]]は、*.jar にしか対応してないので、*.zip なら、リネーム |
*server.xml の編集 | *server.xml の編集 | ||
**$CATALINA_HOME/conf/server.xml | **$CATALINA_HOME/conf/server.xml | ||
| − | **Web アプリケーションの Context に | + | **Web アプリケーションの Context に [[R]]esource を設定 |
<Host name="localhost" | <Host name="localhost" | ||
: | : | ||
<Context path="/DBTest" docBase="DBTest" | <Context path="/DBTest" docBase="DBTest" | ||
debug="5" reloadable="true" crossContext="true"> | debug="5" reloadable="true" crossContext="true"> | ||
| − | < | + | <[[R]]esource name="jdbc/myoracle" auth="Container" |
type="javax.sql.DataSource" | type="javax.sql.DataSource" | ||
| − | driverClassName="oracle.jdbc. | + | driverClassName="oracle.jdbc.[[Oracle]]Driver" |
url="jdbc:oracle:thin:@127.0.0.1:1521:mysid" | url="jdbc:oracle:thin:@127.0.0.1:1521:mysid" | ||
username="scott" password="tiger" maxActive="20" maxIdle="10" | username="scott" password="tiger" maxActive="20" maxIdle="10" | ||
| 38行目: | 38行目: | ||
*web.xml の設定 | *web.xml の設定 | ||
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" | <web-app xmlns="http://java.sun.com/xml/ns/j2ee" | ||
| − | xmlns:xsi="http://www.w3.org/2001/ | + | xmlns:xsi="http://www.w3.org/2001/[[XML]]Schema-instance" |
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee | xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee | ||
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" | http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" | ||
| 44行目: | 44行目: | ||
: | : | ||
<resource-ref> | <resource-ref> | ||
| − | <description>Oracle Datasource example</description> | + | <description>[[Oracle]] Datasource example</description> |
<res-ref-name>jdbc/myoracle</res-ref-name> | <res-ref-name>jdbc/myoracle</res-ref-name> | ||
<res-type>javax.sql.DataSource</res-type> | <res-type>javax.sql.DataSource</res-type> | ||
| 59行目: | 59行目: | ||
---- | ---- | ||
| − | {{include_html banner_html, "!J2EE"}} | + | {{include_html [[banner_html]], "!J2EE"}} |
2020年2月16日 (日) 04:31時点における最新版
目次
出題範囲
http://suned.sun.co.jp/JPN/certification/compobj.html
開発、検証環境
JDK
Document
XML Schemas for J2EE Deployment Descriptors
http://java.sun.com/xml/ns/j2ee/
TOMCAT
document
http://tomcat.apache.org/tomcat-5.5-doc/index.html
JNDI Datasource
http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html
- 準備
- $CATALINA_HOME/common/lib にJDBCドライバを置く
- Tomcatは、*.jar にしか対応してないので、*.zip なら、リネーム
- server.xml の編集
- $CATALINA_HOME/conf/server.xml
- Web アプリケーションの Context に Resource を設定
<Host name="localhost"
:
<Context path="/DBTest" docBase="DBTest"
debug="5" reloadable="true" crossContext="true">
<Resource name="jdbc/myoracle" auth="Container"
type="javax.sql.DataSource"
driverClassName="oracle.jdbc.OracleDriver"
url="jdbc:oracle:thin:@127.0.0.1:1521:mysid"
username="scott" password="tiger" maxActive="20" maxIdle="10"
maxWait="-1"/>
</Context>
:
</Host>
- web.xml の設定
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4"> : <resource-ref> <description>Oracle Datasource example</description> <res-ref-name>jdbc/myoracle</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref> : </web-app>
- コードサンプル
Context initContext = new InitialContext();
Context envContext = (Context)initContext.lookup("java:/comp/env");
DataSource ds = (DataSource)envContext.lookup("jdbc/myoracle");
Connectionconn = ds.getConnection();
{{include_html banner_html, "!J2EE"}}
© 2006 矢木浩人