Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Persistance external File JPA
icon3.gif  Persistance external File JPA [message #1703882] Wed, 05 August 2015 15:23 Go to next message
Frithjof Ebert is currently offline Frithjof EbertFriend
Messages: 1
Registered: August 2015
Junior Member

I've been looking for a solution to a problem for quite some time. I'm writing a program based on data bases. I'm using JPA and in the IDE netbeans the data base is entered via meta-inf / persistance.xml.

But now I want users to be able to use their own data bases with their installations.

Currently my persistance looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="" xmlns:xsi="" xsi:schemaLocation="-// -://">
   <persistence-unit name="SERVICE" transaction-type="RESOURCE_LOCAL">
    <provider>org. eclipse.persistence.jpa.PersistenceProvider</provider>
      <property name="javax.persistence.jdbc.url" value="jdbc:mysql://"/>
      <property name="javax.persistence.jdbc.user" value="DBUSER"/>
      <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
      <property name="javax.persistence.jdbc.password" value="PASSWORD"/>
      <property name="javax.persistence.schema-generation.database.action" value="create"/>

But I need some possibility for the user to have a config file, which is at the same folder as the JAR to enter his data base.

Namely, username, password, data base name, data base port and server address.

How can I do that? Unfortunally, I have not found anything that worked out yet.
I'm only starting to learn...

Thanks in advace,


Re: Persistance external File JPA [message #1704877 is a reply to message #1703882] Mon, 10 August 2015 11:21 Go to previous message
Reiner Lott is currently offline Reiner LottFriend
Messages: 4
Registered: August 2013
Junior Member
Hi Frithjof,

i would solve this problem for your case as follows:

1. Create a gui where the user can enter:
- his database name
- and also the other parameters which are needed "user name" and "password", ...

2. and bypass this arguments included in a map while creating the entitymanagerfactory.

EntityManagerFactory emf = Persistence.createEntityManagerFactory("SERVICE", getRuntimeConfig());

final Map<String, Object> runtimeConfig = new HashMap<String, Object>();
runtimeConfig.put("javax.persistence.jdbc.user", guiValue1);
runtimeConfig.put("javax.persistence.jdbc.password", guiValue2);


[Updated on: Mon, 10 August 2015 11:23]

Report message to a moderator

Previous Topic:NoSuchMethodError due to EclipseLink internal weaving?
Next Topic:Issue with EclipseLink "ValidationException"
Goto Forum:

Current Time: Tue Feb 27 21:24:23 GMT 2024

Powered by FUDForum. Page generated in 0.02055 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top