在运行时修改persistence.xml [英] Modify persistence.xml on runtime

查看:65
本文介绍了在运行时修改persistence.xml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个使用JPA的程序,并将其部署在一个jar中.我希望修改(或在菜单项中询问用户)与数据库服务器的连接数据的配置.

是否可以即时"修改服务器的数据(用户,密码,ip)?

(我对我的英语不好表示歉意)

解决方案

JPA规范不允许对持久性单元进行动态修改.一些实施方式可以提供动态定义持久性单元的特定于实施方式的方式.使用DataNucleus JPA,我们可以按照本页

I'm developping a program that uses JPA, and I deployed it in a single jar. I wish to modify (or ask to the user, in an menú item) the configuration of the connection data with the database server.

It's possible to modify the data (user, password, ip) of the server "on the fly"?

(I apologize my bad english)

解决方案

The JPA spec doesn't allow for dynamic modification of persistence-units. Some implementations may provide an implementation-specific way of defining a persistence-unit dynamically. With DataNucleus JPA we do it as per the foot of this page

这篇关于在运行时修改persistence.xml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆