0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【環境構築】OracleEXPRESSをを接続してみる

Last updated at Posted at 2025-02-02

資材入手

Oracle Database Express Edition(XE)をダウンロードする
https://www.oracle.com/jp/database/technologies/appdev/xe.html
ダウンロードファイル:OracleXE213_Win64.zip

ログインユーザ

注意
クイックスタートにより、「管理者グループの直接メンバーであるユーザー」が必要といわれていますが、win10 proの場合管理者となるドメインユーザまたは管理者なるローカルユーザで試してみていろいろ不都合が発生して進まないです。結局にローカルのAdministratorでインストールを成功しました。またwin11 proの場合、ドメインユーザ+サーバの管理者グループで問題なくインストール成功になります。

インストール

zipファイルを解凍する。
image.png
image.png
image.png
image.png
image.png
image.png

インストール成功後、SQLPlusで試します。Oracleのユーザはsystemを利用します。
image.png

ドメインユーザ向けの設定

C:\app\Administrator\product\21c\homes\OraDB21Home1\network\admin\sqlnet.ora にSQLNET.AUTHENTICATION_SERVICESの設定をコメントします。インストールはローカルAdministrator、利用時ドメインユーザなので、互いに別々のドメインですが、認証システムが違うから、Windows Native Authentication(NTS)を利用できません。

# sqlnet.ora Network Configuration File: C:\app\Administrator\product\21c\homes\OraDB21Home1\NETWORK\ADMIN\sqlnet.ora
# Generated by Oracle configuration tools.

# This file is actually generated by netca. But if customers choose to 
# install "Software Only", this file wont exist and without the native 
# authentication, they will not be able to connect to the database on NT.

# SQLNET.AUTHENTICATION_SERVICES= (NTS)
NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)

修正後、Oracleを再起動します。Oracle Instance Managerを利用して、サービスを停止と再起動を行います。
image.png
image.png
image.png
image.png
SQLPlusでもう一回確認します。
image.png

javaアプリの接続テスト

hellworldのサンプルプログラムをtomcatのwebappsフォルダに入れます。
META-INF/context.xmlにOracleEXPRESSの接続を設定します。

	<Resource
		name			=	"jdbc/efw"
		auth			=	"Container"
		type			=	"javax.sql.DataSource"
		driverClassName	=	"oracle.jdbc.driver.OracleDriver"
		url				=	"jdbc:oracle:thin:@localhost:1521"
		username		=	"system"
		password		=	"password"
		maxTotal		=	"10"
		maxIdle			=	"10"
		maxWaitMillis	=	"10"
	/>

OracleEXPRESSに専用データベースまたはスキーマを作成するため、結構手間がかかるため、別途調査しますが、一旦systemユーザで凌ぎます。

インストールフォルダの中からojdbc8.jarまたはojdbc11.jarを見つかります。一つをコピーしてhelloworld/WEB-INF/libに入れます。ほかのいろいろもありますが、「g」はグローバルの意味です。「dms」は、Dynamic Monitoring Service (DMS) の意味です。
image.png
tomcatを起動します。コンソール画面からデータベース起動成功のログを確認します。
image.png
dbテスト画面で動作確認します。
image.png
※Oracleの場合外だしSQL xmlファイルの記載に。「;」を書いたらSQLエラーになります。ちょっとがかっりです。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?