N
N
Nikolay Baranenko2017-06-07 10:50:33
Java
Nikolay Baranenko, 2017-06-07 10:50:33

How to properly configure JNDI for a specific WEB APP?

Hello.

I want to take advantage of the possibility of using JNDI for a web application (Tomcat) in terms of connections to the DBMS.

To do this, in the web application, in the META-INF folder, I created the context.xml file
and registered the connection in it

<Context reloadable="true">
    <Resource name="jdbc/Oracle" auth="Container"
              type="javax.sql.DataSource"
              driverClassName="oracle.jdbc.driver.OracleDriver"
              url="jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=oracledb)))"
              username="dbuser"
              password="db123"
              maxActive="150"
              maxIdle="120"
              maxWait="-1"/>
</Context>


is it possible to use
it as a named reference
@Resource(name = "jdbc/Oracle")
private DataSource dataSource;

without additional editing of files in APACHE_TOMCAT_DIR/conf/?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
P_Alexander, 2018-01-10
@P_Alexander

Hello, I understand that I’m talking a little off topic, but I also have problems with this file,
maybe you can help, the problem is with this line url="jdbc:mysql://localhost:3306/warmstar?autoReconnect=true&useSSL =false&useLegacyDatetimeCode=false&serverTimezone=UTC"
I don't understand why the environment underlines these characters & if without additional settings, then time zone errors fly, I tried using : and ; but to no avail, is it possible to somehow take out these additional settings separately, or some kind of working example where they use additional settings in one line ???

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question