Reputation: 383
I am trying to connect my local host database in my android application but I got this error
2021-08-29 15:27:54.859 7973-7973/com.example.invoices D/Amado: com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
I looked every where in the internet but non of the solution worked for me
here is my code:
package com.example.invoices
import android.util.Log
import java.sql.SQLException
import java.sql.DriverManager
import java.sql.Connection
object DBConncection {
@JvmStatic
fun connection(){
try{
val conn = DriverManager.getConnection(
"jdbc:mysql://127.0.0.1:3306/invoices", "root", "123");
Log.d("Amado","Success")
}
catch (e: SQLException){
Log.d("Amado",e.toString())
}
}
}
I am using android studio, kotlin language, trying to connect to maridb installed as service from xampp the database is working fine
I added mysql connector version 8.0.11 to the project by pasting the jar file in the lib folder->right click on the file and Add as library option
Upvotes: 0
Views: 2833