Connect android application to MYSQL database
<p>When i try to connect android application to MYSQL database server the following errors occurs.i am using android studio in linux mint:</p>

<blockquote>
  <p>05-10 10:46:58.555 29599-29599/com.example.pc.hms_treva  D/Atlas:
  Validating map...  05-10 10:46:58.660
  29599-29619/com.example.pc.hms_treva I/OpenGLRenderer: Initialized
  EGL, version 1.4  05-10 10:46:58.743
  29599-29619/com.example.pc.hms_treva D/OpenGLRenderer: Enabling debug
  mode 0 05-10 10:46:58.787 29599-29619/com.example.pc.hms_treva
  W/EGL_emulation: eglSurfaceAttrib not implemented  05-10 10:46:58.787
  29599-29619/com.example.pc.hms_treva W/OpenGLRenderer: Failed to set
  EGL_SWAP_BEHAVIOR on surface 0xaf0355c0, error=EGL_SUCCESS</p>
</blockquote>

<p>Here is code:</p>

<pre><code>public class MainActivity extends Activity {
ImageView prev, now, next;
TextView display, bottom;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    prev = (ImageView) findViewById(R.id.previmg);
    now = (ImageView) findViewById(R.id.token);
    next = (ImageView) findViewById(R.id.nextimg);
    display = (TextView) findViewById(R.id.textView2);
    bottom = (TextView) findViewById(R.id.tokennum);

    prev.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Connect runner = new Connect();
            //  String sleepTime = time.getText().toString();
            runner.execute();
        }
    });
    now.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent i=new Intent(getApplicationContext(),StatusUpdate.class);
            startActivity(i);
        }
    });
}


class Connect extends AsyncTask&lt;String, String, String&gt; {

    MainActivity m = new MainActivity();

    @Override
    protected String doInBackground(String... params) {
        return null;

    }

    protected void onPreExecute() {
        try {
            Class.forName("net.sourceforge.jtds.jdbc.Driver").newInstance();

        } catch (InstantiationException e1) {
            e1.printStackTrace();
        } catch (IllegalAccessException e1) {
            e1.printStackTrace();
        } catch (ClassNotFoundException e1) {
            e1.printStackTrace();
        }
        String username = "qqq";
        String password = "dddd";
        Connection DbConn = null;
        try {
            DbConn = DriverManager.getConnection("jdbc:jtds:sqlserver://xxx.xxx.x.x:1433/DATABASE NAME;user=" + username + ";password=" + password);
            Log.i("Connection","open");
            Toast.makeText(getApplicationContext(),"coonnected",Toast.LENGTH_LONG).show();
        } catch (SQLException e1) {

            e1.printStackTrace();
        }

        Log.w("Connection", "open");
        Statement stmt = null;
        try {
            stmt = DbConn.createStatement();
        } catch (SQLException e1) {
            e1.printStackTrace();
        }
        ResultSet reset = null;
        try {
            reset = stmt.executeQuery(" select TOKENID from DEPTVISIT where DEPVISITID=1 ");
            display.setText(reset.getString(1));
        } catch (SQLException e1) {
            e1.printStackTrace();
        }


        try {
            DbConn.close();
        } catch (SQLException e1) {
            e1.printStackTrace();
        }

    }
}

}
</code></pre>