Q
Q
QFCFC2018-07-12 15:14:14
Java
QFCFC, 2018-07-12 15:14:14

How to create a db connection through persistence.xml?

One way to connect a program to a database is using the resources/META-INF/persistence.xml file.
It needs to be written

<persistence>
   <persistence-unit name="MyPU">
      <jta-data-source>MyDataSource</jta-data-source>
      ...
   </persistence-unit>
</persistence>

The question is where and how to create a DataSource (database connection settings) in order to access these settings through the name MyDataSource.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2018-07-12
@QFCFC

In the JNDI service of the application server.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question