UnsupportedOperationException with DriverManager.getConnection() on Android

后端 未结 2 1787
广开言路
广开言路 2020-12-04 00:59

I am unable to connect JDBC to my database, getting following error

Error :  E/AndroidRuntime: FATAL EXCEPTION: main
 Process: com.example.myprojectapplicati         


        
相关标签:
2条回答
  • 2020-12-04 01:42

    According to the stacktrace, the MySQL Connector/J version you are using is using a java.util.regex.Matcher feature not supported on Android (probably named groups). The workaround is to use a 5.1.x version of MySQL Connector/J instead of a 8.0.x version.

    However, you shouldn't use JDBC from Android applications. It is insecure, and generally badly performing to connect to a database directly. The proper solution is to write a REST service (or other form of webservice) to mediate between your Android application and the database.

    0 讨论(0)
  • 2020-12-04 01:52

    Probably means that the msql driver information in your configuration does not match the load driver in your code. The high version of the mysql driver registration, try to use this method: Class.forName("com.mysql.cj.jdbc.Driver");

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