Android Studio: Connect to Database without JSON

Many Developers out there are still looking for the easier and simple means to connect to database with less codes without using JSON or any server side programming language.

well there is an alternative to that. Using Library (jdbc or jdts) these are the drivers which will help to connect your app to mysql database.

Good advantage of using this is you will be able to use remote server connection to yours connection string.

To get your server ip address: Go to start menu RUN > type CMD then command prompt will display. now write ipconfig/all , copy the ipv4 address and use it as server address.

Below is a java connection class.

package com.example.msangi.idoctorapp;
import android.annotation.SuppressLint;
import android.os.StrictMode;
import android.util.Log;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

* Created by MSANGI on 4/16/2020.

public class ConnectionDB{
Connection conn = null;
public Connection CON() {
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
try {
conn = DriverManager.getConnection("jdbc:mysql://","username","password");

} catch (SQLException se) {
Log.e("ERROR", se.getMessage());
} catch (ClassNotFoundException e) {
Log.e("ERROR", e.getMessage());
} catch (Exception e) {
Log.e("ERROR", e.getMessage());
return conn;

Leave a Reply

Your email address will not be published. Required fields are marked *