Android + MySQL using com.mysql.jdbc.Driver

后端 未结 4 2146
無奈伤痛
無奈伤痛 2020-12-02 02:13

I am writing an Android application that will connect to a MySQL server. For now, I am testing the MySQL server on my computer through XAMPP using http://localhost:3306/. T

相关标签:
4条回答
  • 2020-12-02 02:53

    Use JDBC connector mysql-connector-java-3.0.17-ga-bin.jar, for now is the only one that works.

    Check your code also, you need to implement a pool of connections for each activity of your application, just add a private "Connection" var and initialize that in your OnCreate method like con = DriveManager.getConnection...... then use that private var every time you need to access MYSQL.

    0 讨论(0)
  • 2020-12-02 02:57

    An other approach is to use a Virtual JDBC Driver that uses a three-tier architecture: your JDBC code is sent through HTTP to a remote Servlet that filters the JDBC code (configuration & security) before passing it to the MySql JDBC Driver. The result is sent you back through HTTP. There are some free software that use this technique. Just Google "Android JDBC Driver over HTTP".

    0 讨论(0)
  • 2020-12-02 02:57

    To provide a connection to a remote database in android, will be necessary to use WebService because the android does not have an API to connect to remote database.

    0 讨论(0)
  • 2020-12-02 03:19

    Have you tried looking at ContentProviders? http://developer.android.com/guide/topics/providers/content-providers.html

    You will probably have more luck accessing data through an implementation of that (SQLite database for example) than accessing MySQL directly.

    0 讨论(0)
提交回复
热议问题