• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to create datasource for standalone application using JPA

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 959
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.


 
reply
    Bookmark Topic Watch Topic
  • New Topic