java - 如何在eclipse中用sql数据库表导出war文件

标签 java sql eclipse

<分区>

我在 Eclipse 中创建了一个 Java EE Technologies 动态 Web 项目。该项目在其中创建了一个数据库。在具有 Tomcat 服务器的本地机器上测试它工作正常。我想将这个带有数据库的项目部署到另一个运行 Tomcat 的系统。因为我需要将我的项目交付给客户。如何完成这个任务?

有没有可能用sql表构建war文件。

最佳答案

在大多数情况下,答案是,您不能使用用 eclipse 创建的嵌入式数据库导出 .war。

您必须单独导出数据库文件并将它们上传到生产服务器上。这通常意味着您必须安装在开发和导出 DDL 和表数据时使用的数据库服务器。

在您的特定情况下(MySQL 和 Tomcat)我们可以说 MySQL is not built for embedded use , 除非使用过时且不完整的 MySQL Embedded Library for Java ,这将导致您对项目数据库配置进行一些重大更改。

你完全可以改变你的数据库服务器,从 MySQL 切换到 DerbyH2 (为此感谢@specializt)它有可能将服务器直接嵌入到你的 war 中。

这直接取自 Eclipse Corner Article on Creating Database Web Applications with Eclipse .

注意!!:链接的文章已弃用,因此您不应完全依赖它。引用的部分对您的情况仍然很敏感,并且涵盖了 Derby 数据库部署。

Deploying the Database

When you are ready to deploy the application to a production Tomcat application server, you must copy the Derby database data folders to the application server computer. You then have a couple of options for accessing the Derby database from your deployed application.

You can install Derby on the application server computer, and run it in client/server mode. Your application connects to the database using the same technique as I've demonstrated in this article. The drawback to this approach is that you have two server processes to manage: Tomcat and Derby.

You can use Derby in embedded mode. In this scenario, the Derby engine runs inside the Tomcat process. You don't have to stop and start Derby separately from Tomcat. For more information, refer to the Derby website.

关于java - 如何在eclipse中用sql数据库表导出war文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26400323/

相关文章:

java - 如何使用java将xml文件数据插入mongodb数据库?

java - 从 Java API 运行 OpenOffice 宏

php - 优化 sql select 嵌套 where 查询

sql - 家谱的递归 CTE 不递归

eclipse - Git check out 多个同名文件

java - 强制热点频繁GC?

java - swing 中布局的动态变化

sql - H2 获取所有表的行数

eclipse - Eclipse中单独文件的 Bootstrap LESS变量上下文

Java/Eclipse : returning to List casted Map. 值()