R
R
run1822016-12-28 21:24:42
Java
run182, 2016-12-28 21:24:42

How to connect Android application to MySQL using JDBC?

Friends, help!
Here is the code in e.getMessage() returns the error "No Suitable Driver":

try {
                    //Class.forName("com.mysql.jdbc.Driver");
                    Connection conn = DriverManager.getConnection(
                            "jdbc:mysql://myserver.ru/",
                            "***",
                            "******"
                    );
                } catch (SQLException e) {
                    e.getMessage();
                }

As I understand it, I need to connect the driver, but when I uncomment the line with the connection, it gives an Android Studio error - Unhandled exception java, lang.ClassNotFoundException.
You need MySQL, not SQLite. there will be a messenger.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rou1997, 2016-12-28
@Rou1997

Dalvik does not include a driver for MySQL, download separately - download and add the MySQL java connector library.
Firstly, SQLite, and secondly, why not make a full-fledged back-end (REST API) on the server, didn't you think that direct access to the server's database is very dangerous?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question