带有即插即用数据库的Java应用程序(Java Application with plug and play db)

我的公司有一种产品,我们作为解决方案出售给平庸的公司,他们可以使用java,但由于许可和其他技术/资源问题,他们对db有不同意见。 我想知道是否有办法以这种方式创建应用程序,在安装过程中我们配置数据库(选择天气mysql / oracle和输入/生成连接字符串,分配驱动程序等),它的工作方式与其他数据库类似。 我听说过hibernate能够生成表但以前没有用过它。 我需要一个意见,如果可能,请参考指南。 先进的谢谢你。 对于一个愚蠢的问题抱歉,我只知道java的基础知识,还没有在ORM或任何其他框架上工作。

My company has a product that we sell as a solution to mediocre firms, they are ok with using java but they have different opinions on db due to licensing and other technical/resource issues. I was wondering if there is a way i can create the app in such a way that during installation we configure the database (select weather mysql/oracle and input/generate connection strings, allocate driver, e.t.c.) and it works similarly as the other db. I have heard about hibernate being able to generate table but havent ever worked on it before. I need an opinion and if possible reference to a guide. thank you in advanced. sorry for a stupid question, i only know basics of java, haven't yet worked on ORM or any other framework.

最满意答案

是,

JPA(java persistance API)允许您执行您正在寻找的内容。 您将需要一个JPA提供程序(例如休眠 , Apache OpenJPA或eclipse链接等)。

您将能够根据您需要映射到的对象自动创建数据库的模式。

以下是几个开始使用的链接:

https://docs.oracle.com/javaee/6/tutorial/doc/bnbpz.html https://www.tutorialspoint.com/jpa/ http://www.oracle.com/webfolder/technetwork/tutorials/obe/java/SettingUpJPA/SettingUpJPA.htm

许多JPA资源将指向java资源和教程,因为它大量使用java entreprise edition,但是API本身可以与标准java平台一起使用。

Yes,

The JPA (java persistance API) allows you to do what you're looking for. You will be needing a JPA provider (such as hibernate, Apache OpenJPA or eclipse link among others).

You will be able to automatically create the schema of your database according to the objects you need to map into it.

Here are few links to get started:

https://docs.oracle.com/javaee/6/tutorial/doc/bnbpz.html https://www.tutorialspoint.com/jpa/ http://www.oracle.com/webfolder/technetwork/tutorials/obe/java/SettingUpJPA/SettingUpJPA.htm

Many JPA ressources will point to java ee ressources and tutorials, since it is heavily used with java entreprise edition, but the API itself can be used with the standard java platform.

更多推荐