This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to create datasource for standalone application using JPA

 
identita smart
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 959
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
identita smart
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic