我正在尝试将我的Android应用程序连接到MySql服务器,但是它显示了我无法解决的错误。我正在为我的SQL Server使用主机

时间:2019-10-07 23:18:06

标签: java mysql android-studio jdbc

  1. 导入java.sql.DriverManager;导入java.sql.Connection;导入
    java.sql.PreparedStatement;导入java.sql.SQLException;

       public class DatabaseHandler extends Configs{    Connection dbConnection;
       public Connection getDbConnection()
       throws ClassNotFoundException, SQLException{
    
       String connectionString = "jdbc:mysql://" + dbHost +  ":"+dbHost +"/" + dbName;
    
       Class.forName("com.mysql.cj.jdbc.Driver");
       dbConnection = DriverManager.getConnection(connectionString, dbUserName,dbUserPassword);
       return dbConnection;    }
       public  void sign_up_user(String login, String password){
       String insert ="INSERT INTO " + ConstForDb.TABLE_NAME + "(" + ConstForDb.USERS_LOG + "," +
               ConstForDb.USERS_PASSWORD + ")" + "VALUES(?,?)";
    
      try {
          PreparedStatement preparedStatement = getDbConnection().prepareStatement(insert);
          preparedStatement.setString(1 ,ConstForDb.USERS_LOG);
          preparedStatement.setString(2 , ConstForDb.USERS_PASSWORD);
          preparedStatement.executeUpdate();
      }
      catch (SQLException e) {
          e.printStackTrace();
      } catch (ClassNotFoundException e) {
          e.printStackTrace();
      }    }; }
    

我得到了我无法解决的错误:

       Caused by: java.lang.BootstrapMethodError: Exception from call site #37 bootstrap method
       at com.mysql.cj.jdbc.AbandonedConnectionCleanupThread.<clinit>(AbandonedConnectionCleanupThread.java:58)
       at java.lang.Class.classForName(Native Method)
       at java.lang.Class.forName(Class.java:453)
       at java.lang.Class.forName(Class.java:378)
       at com.mysql.cj.jdbc.NonRegisteringDriver.<clinit>(NonRegisteringDriver.java:99)
       at java.lang.Class.classForName(Native Method)
       at java.lang.Class.forName(Class.java:453)
       at java.lang.Class.forName(Class.java:378)
       at batyr.project.kaitaxi.DatabaseHandler.getDbConnection(DatabaseHandler.java:20)
       at batyr.project.kaitaxi.DatabaseHandler.sign_up_user(DatabaseHandler.java:30)
       at batyr.project.kaitaxi.Reg.accept_reg(Reg.java:84)
       at java.lang.reflect.Method.invoke(Native Method) 
       at androidx.appcompat.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:385) 
       at android.view.View.performClick(View.java:6294) 
       at android.view.View$PerformClick.run(View.java:24770) 
       at android.os.Handler.handleCallback(Handler.java:790) 
       at android.os.Handler.dispatchMessage(Handler.java:99) 
       at android.os.Looper.loop(Looper.java:164) 
       at android.app.ActivityThread.main(ActivityThread.java:6494) 
       at java.lang.reflect.Method.invoke(Native Method) 
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) 
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) 
    Caused by: java.lang.NoClassDefFoundError: Invalid descriptor: VLLI

- List item

................................. ........................... ........................

0 个答案:

没有答案