デバイス接続
ojdbc6.JAr javaとoracle間の通信プロトコル
http://tomcat.apache.org/tomcat-9.0-doc/jndi-datasource-examples-howto.html#Oracle_8i,_9i_&_10g
public static Connection 디비연결() {
try {
Context initContext = new InitialContext();
Context envContext = (Context) initContext.lookup("java:/comp/env");
DataSource ds = (DataSource) envContext.lookup("jdbc/myoracle");
Connection conn = ds.getConnection();
System.out.println("db연결성공");
return conn;
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("연결실패");
return null;
}

2.WEB.INFの中にWebがありますxmlファイルの作成
jdbc/myoracleこれはcontextですxmlの名前と一致する必要があります
<web-app version="4.0"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd">
<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>

3.META-INFのcontext.xmlファイルの作成
context.xmlをメモリにアップロードするときに1回実行
oracle.jdbc.driver.OracleDriverには、すべてのルールのライブラリが含まれています.
driverClassName="oracle.jdbc.driver.OracleDriver"
driverClassName="oracle.jdbc.OracleDriver"以前の
127.0.0.1返信ip私のそばに戻ったip
1521接続->ポート番号
mysid -> xe
maxTotal="20"maxIdle="10"最大10個の同時接続を作成
<Context>
<Resource name="jdbc/myoracle" auth="Container"
type="javax.sql.DataSource" driverClassName="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:@127.0.0.1:1521:xe"
username="cos" password="cos1234" maxTotal="20" maxIdle="10"
maxWaitMillis="-1"/>
</Context>

4.デバイス接続をテストするためにwebappにjspファイルを作成する
<%@page import="com.cos.blog.db.DBConn"%>
<%
DBConn.디비연결();
%>
エラーが発生した場合は、oraclexeサービスが実行されているかどうかを確認します.Reference
この問題について(デバイス接続), 我々は、より多くの情報をここで見つけました https://velog.io/@mireat/디비연결テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol