0

I have developped a JAR that extract Oracle record's list and generate a Excel file. This program can be started alone, directly from shell. The connection parameters (database, userid, password) are passed in a configuration file.

Now, I have integrated this program in a J2EE application that use JPA and QueryDsl to work with Oracle database.

The program work well but it need to open a new JDBC connection every time I will generate a new Excel file.

J2EE application has a lot of connections already open and I'm interesting to use one of them.

How can I obtain a JDBC connection from JPA and pass it to my JAR ?

If this is not possible from JPA, can I do that using EclipseLink JPA provider ?

schlebe
  • 2,798
  • 4
  • 36
  • 45
  • JPA doesn't provide an API for getting a connection, each provider has its own way. Also some JPA provider(s) also provide a way of generating an Excel file. –  Feb 19 '18 at 16:06
  • It is be possible - see [this](https://stackoverflow.com/a/3497206/6413377) - **but might be unwise** since JPA handles its own connections and there might be even possibility that connection is closed after a while even used by your jar, not sure. So if you cannot change the jar to use JPA I would stick to creating own JDBC connections. – pirho Feb 19 '18 at 19:39
  • 1
    Why not define it to use the server managed data source instead of direct jdbc connection – osama yaccoub Feb 19 '18 at 20:25
  • @DN1: I use EclipseLink as JPA provider. I have added this information in my question. – schlebe Feb 20 '18 at 05:56

0 Answers0