如何从Android应用程序连接到MySQL数据库?连接到、应用程序、数据库、Android

2023-09-12 10:37:21 作者:此心╮为你上了锁

我想连接到托管在同一台服务器从我的Andr​​oid应用程序在Tomcat服务器上,而无需使用PHP MySQL数据库。有没有办法做到这一点?我找到了一些解决方案,但都使用PHP。

I would like to connect to a MySQL Database hosted on the same server with a Tomcat Server from my Android App without using PHP. Is there any way to do this? I found some solutions but all use PHP.

我可以直接连接还是必须通过Web服务器来做到这一点?

Can I connect directly or do I have to do it through a Web server?

推荐答案

由于您是在Tomcat上运行我想访问该数据库将是编写处理应用程序和服务器之间的通信的Web服务的最佳途径。

Because you're running on Tomcat I imagine the best way to access the database would be to write a webservice that handles the communication between the app and the server.

web服务将被写入在Java中使用JSP Tomcat的运行。

The webservice will be written in Java to run on TomCat using JSP.

我猜你想直接与MySQL数据库进行通信(即运行在数据库中直接SQL命令),但我不认为你可以做到这一点(虽然从来没有尝试过,或看着它),我有一直是根据你所需要的服务器上的某些code坐其间的IM pression。

I'm guessing you're trying to communicate directly with the MySQL database (i.e. run SQL commands on the database directly) but I don't think you can do this (although never tried or looked into it), I have always been under the impression that you need some code on the server to sit inbetween.