Is it possible to embed a MySQL database server into a Java servlet?

China☆狼群 提交于 2019-12-11 11:01:17

问题


I am in a situation where I am being asked to make a single WAR file that runs Wordpress. Using Quercus, Tomcat and httpd+mod_rewrite I was able to make a WAR file containing everything except the database, which I ran externally. However, I'm not sure how I might go about removing the dependency upon an external database (and, frankly, this whole endeavor seems like a bad idea to me).

This article describes how Wordpress has been successfully deployed on the Google App Engine and hence without needing MySQL, but this was done using JPA.

Instead of embedding a MySQL instance, if I could use an external MSSQL database connection instead that would be fine too. (This is an old post, but it seems to suggest that real MySQL is the only supported database for Wordpress.) Is the most viable option to attempt to replace each MySQL call in the Wordpress source code to a MSSQL call? Is there some kind of compatibility/translation layer that I could use instead? (I saw this question, but the solution will not work in my case.)

UPDATE: I came across MySQL-JE, but it looks out of date and not quite complete enough (not sure how I would tell Quercus/PHP to communicate with it). Has anyone used it? If so, do you think it would help solve this problem?


回答1:


Embedded Database

According to this chart, MySQL is not built for embedded use.

I can point you to two pure Java database engines for embedding in a Java app. Both are open-source, free of cost, and under active development. Both have a good pedigree with a long line of database development history behind them.

  • H2
  • Derby

WordPress Requires MySQL

According to this WordPress Requirements page, specifically MySQL is required. That's annoying. The main point of SQL is to avoid database-vendor lock-in.



来源:https://stackoverflow.com/questions/20621309/is-it-possible-to-embed-a-mysql-database-server-into-a-java-servlet

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!