Marwen Trabelsi
Marwen Trabelsi

Reputation: 4257

the same database for a web application + desktop application

As part of a project, I have to develop a web application and a server written in Java. I am familiar with JPA and the H2 database under Netbeans, so I'd like to use both in my project.

My question is: Is it possible to use the same database in a web and desktop application with JPA and H2 as the database, without Tomcat & Glassfish as described in this link ?

Edit: I thought tomcat is a DBMS as H2 database, Mysql ...the answer is simply yes, I Can use the same database for both...but i need to use tomcat, glassfish or any kind of web container (Server Application) only for the web application,the DBMS is an independent thing: I can use H2, apach derby...

for JPA I must follow the tutorial described in the link.

Upvotes: 0

Views: 544

Answers (1)

Tomasz Nurkiewicz
Tomasz Nurkiewicz

Reputation: 340713

Your question isn't completely clear, so let me guess:

  • you can reuse the same database, but it has to work in server mode, not accessing the disk directly. This way both the web application and your desktop app will use the sama data source at the same time.

  • you can also reuse datbase-related code (entities, DAOs), etc. JPA spec. is not coupled with Java EE, you can easily use it in standalone application. Simply extract database-code into a separate artifact (if you have been following MVC or any other sane architecture, it should be simple) that does not have dependencies on servlets/controllers.

UPDATE: So it seems there was a major misconception in your understanding of the stack. You need: databse server (DBMS) like , or full-blown like or . Your application communicates with a database and is deployed to an application server/servlet container like or . Fianlly is used to ease the database access.

Upvotes: 3

Related Questions