JavaoracleDB Connection Pool

Asked 1 years ago, Updated 1 years ago, 61 views

Hello, I am learning the web application through eclipse. I have a question while I am currently working on inserting and printing data in conjunction with Eclipse using the oracle developer database.

When it comes to using the connection pool, First of all, I have a question because I don't understand the name and type part in the context part of tomcat. As for the type, I wonder if you called in the method DataSource and designated it. Also, in the name part, I wonder if the user sets it arbitrarily or if there is a unique name for each oracle db.

And I know that you call datasource to DAO and use connection pool.

datasource = (DataSource)context.lookup("java:comp/env/jdbc/Oracle11g");

Declare the datasource object and look up with context, but I don't know what the string part in the lookup means.

I'm asking because I don't deal with this much even if I look it up on the Internet. I'd appreciate it if you could explain it if you know.

java oracledb eclipse

2022-09-22 18:51

1 Answers

You should first understand JNDI (Java Naming and Directory Interface).

Simply put, it maps objects through names.

For each oracle db, you can think of it as a jndi object-specific name rather than a unique name. If you have multiple oracle db, you have multiple jndi objects. Also, it's not just DB that can be registered.

type is the class you want to use. That's why I cast the results of the look-up as DataSource.

Take Tomcat as an example based on the content of the question.

When the web application is deployed, a jndi object named Oracle11g is registered. name=jdbc/Oracle11g, type=javax.sql.DataSource and so on.

This jndi object is placed in the java:comp/env portion of the JNDI namespace. (According to Tomcat's website) javax through this.The lookup method of the name.Context class finds jndi objects that match the name.

http://tomcat.apache.org/tomcat-8.0-doc/jndi-resources-howto.html It would be helpful if you read it.

Add +++++

https://www.holaxprogramming.com/2013/01/10/devops-how-to-manage-dbcp/

http://d2.naver.com/helloworld/5102792


2022-09-22 18:51

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.