title: Android studio JDBC MySQL
body: <p>I am trying to solve this problem for 4 hours and I am completely without hope.</p>
  
  <p>I am using android studio for coding this application. I have created a simple activity which holds edit field for user name and password and next there is a button which is meant to be to submit data from these two edit fields.</p>
  
  <p>I am using mysql connector/j and the java code is following:</p>
  
  <pre><code>package allanko.quizzerappandroid;
  
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.widget.TextView;
  
  import java.sql.*;
  
  public class LoginActivity extends AppCompatActivity
  {
      private static CDatabase db;
  
      @Override
      protected void onCreate( Bundle savedInstanceState )
      {
          super.onCreate( savedInstanceState );
          setContentView( R.layout.activity_login );
  
          db = new CDatabase();
      }
  
    /*
      public static CDatabase getDB()
      {
        return db;
      }*/
  
      public class CDatabase
      {
          private String db_name;
          private String db_user;
          private String db_pass;
          private Connection connection;
          private boolean isConnected;
  
          public CDatabase()
          {
              db_name = "jdbc:mysql://localhost:3306/quizzer?useSSL=false";
              db_user = "quizzer";
              db_pass = "pass";
              connection = null;
  
              if( connect() == true )
                isConnected = true;
              else
                isConnected = false;
              printResult();
          }
  
          private boolean connect()
          {
              try
              {
                connection = DriverManager.getConnection( db_name, db_user, db_pass );
                return true;
              }
              catch( Exception exc )
              {
                exc . printStackTrace();
                return false;
              }
          }
  
        private void printResult()
        {
            TextView dbText = (TextView)findViewById( R.id.dbText );
  
            if( ! isConnected )
              dbText . setText( "Connection to database failed" );
            else
              dbText . setText( "Connected to database." );
        }
  
        public ResultSet query( String query) throws SQLException
        {
            Statement statement = connection . createStatement();
            return statement . executeQuery( query );
        }
  
        public boolean isConnected()
        {
            return isConnected;
        }
      }
  }
  </code></pre>
  
  <p>When I start this application on whether emulator or my phone, it every time write "Connection to database failed." and I am getting this from console:</p>
  
  <pre><code>W/art: Common causes for lock verification issues are non-optimized dex code
  W/art: and incorrect proguard optimizations.
  W/art: Class android.support.v4.util.LruCache failed lock verification and will run slower.
  W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
  W/System.err: java.sql.SQLException: java.lang.VerifyError: Verifier rejected class com.mysql.jdbc.CharsetMapping: void com.mysql.jdbc.CharsetMapping.&lt;clinit&gt;() failed to verify: void com.mysql.jdbc.CharsetMapping.&lt;clinit&gt;(): [0x4287] Invalid reg type for array index (Precise Reference: com.mysql.jdbc.MysqlCharset[]) (declaration of 'com.mysql.jdbc.CharsetMapping' appears in /data/app/allanko.quizzerappandroid-1/base.apk)
  W/System.err:     at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:963)
  W/System.err:     at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:896)
  W/System.err:     at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:885)
  W/System.err:     at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:860)
  W/System.err:     at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:877)
  W/System.err:     at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:873)
  W/System.err:     at com.mysql.jdbc.Util.handleNewInstance(Util.java:422)
  W/System.err:     at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:410)
  W/System.err:     at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:328)
  W/System.err:     at java.sql.DriverManager.getConnection(DriverManager.java:569)
  W/System.err:     at java.sql.DriverManager.getConnection(DriverManager.java:219)
  W/System.err:     at allanko.quizzerappandroid.LoginActivity$CDatabase.connect(LoginActivity.java:55)
  W/System.err:     at allanko.quizzerappandroid.LoginActivity$CDatabase.&lt;init&gt;(LoginActivity.java:43)
  W/System.err:     at allanko.quizzerappandroid.LoginActivity.onCreate(LoginActivity.java:19)
  W/System.err:     at android.app.Activity.performCreate(Activity.java:6664)
  W/System.err:     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
  W/System.err:     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599)
  W/System.err:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
  W/System.err:     at android.app.ActivityThread.-wrap12(ActivityThread.java)
  W/System.err:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
  W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:102)
  W/System.err:     at android.os.Looper.loop(Looper.java:154)
  W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:6077)
  W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
  W/System.err:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
  W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
  W/System.err: Caused by: java.lang.VerifyError: Verifier rejected class com.mysql.jdbc.CharsetMapping: void com.mysql.jdbc.CharsetMapping.&lt;clinit&gt;() failed to verify: void com.mysql.jdbc.CharsetMapping.&lt;clinit&gt;(): [0x4287] Invalid reg type for array index (Precise Reference: com.mysql.jdbc.MysqlCharset[]) (declaration of 'com.mysql.jdbc.CharsetMapping' appears in /data/app/allanko.quizzerappandroid-1/base.apk)
  W/System.err:     at com.mysql.jdbc.CharsetMapping.getNumberOfCharsetsConfigured(CharsetMapping.java:687)
  W/System.err:     at com.mysql.jdbc.ConnectionImpl.&lt;init&gt;(ConnectionImpl.java:464)
  W/System.err:     at com.mysql.jdbc.JDBC4Connection.&lt;init&gt;(JDBC4Connection.java:47)
  W/System.err:     at java.lang.reflect.Constructor.newInstance0(Native Method)
  W/System.err:     at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
  W/System.err:     at com.mysql.jdbc.Util.handleNewInstance(Util.java:404)
  W/System.err:   ... 19 more
  W/gralloc_ranchu: Gralloc pipe failed
  </code></pre>
  
  <p>I am completely desperate because I tried to google everything that came to my mind and nothing worked.</p>
  
  <p>Thanks in advance for your answers.</p>