0

this is my code

package com.example.mysql_connect

import android.util.Log
import java.sql.Connection
import java.sql.DriverManager
import java.sql.SQLException

object Test{
    @JvmStatic
    fun connectiom(){
        val cn:Connection
        var studentScore: Float
        println("into")
        try {
            Class.forName("com.mysql.cj.jdbc.Driver");
            Log.v("DB", "OK")
        } catch (e: ClassNotFoundException) {
            Log.e("DB", "error")
            return
        }
        try {
            cn=DriverManager.getConnection("jdbc:mysql://localhost:3306/score_system","root","20080905Ww")
            println("ok")
        }catch (e:SQLException){
            e.printStackTrace()
        }
    }
}

my jdbc version is 8.0.28 and mysql database name is "root",password is "20080905Ww" database name is "score_system" but i always can't connection to mysql

this is my error W/System.err: java.sql.SQLNonTransientConnectionException: Could not create connection to database server.

this all error:enter image description here

hope some one help me please thanks

slime0129
  • 1
  • 1

0 Answers0