aspose file tools*
The moose likes Object Relational Mapping and the fly likes How to create datasource for standalone application using JPA Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "How to create datasource for standalone application using JPA" Watch "How to create datasource for standalone application using JPA" New topic
Author

How to create datasource for standalone application using JPA

identita smart
Greenhorn

Joined: Dec 02, 2009
Posts: 5
In the persistence.xml configuration file, we have data source got it from web server configuration file, and created by server like Jboss or tomcat.

I just wonder how to create this same data source via Java stand-alone application?

I have Java standalone application embedded Jetty server running with JPA module. Question is how to setup or create data source from my Java application just like web server; which called by persistence.xml?


Thanks,


Identita
Freddy Wong
Ranch Hand

Joined: Sep 11, 2006
Posts: 959

You can use DataSource such as C3P0. So instead of getting it from the JNDI, you can configure the datasource information in the persistence.xml, e.g.



I assume you use Hibernate


SCJP 5.0, SCWCD 1.4, SCBCD 1.3, SCDJWS 1.4
My Blog
identita smart
Greenhorn

Joined: Dec 02, 2009
Posts: 5
Hi thank,

I know this method, I just don't want users to modify persistence.xml directly. I plan to provide customized format ot properties file, so users can easily change database parameters when application is running their environment. I just wonder how to create data source Java programming just like Java web application server.


 
jQuery in Action, 2nd edition
 
subject: How to create datasource for standalone application using JPA