1

Can I connect an Android app to MySQL database in my computer? Just tell me the way or a library name and let me google it to learn about.

2
  • I do a fast search and i found this: Android Sample and MySQL Reference Commented Aug 1, 2018 at 18:51
  • that will help thank you Commented Aug 1, 2018 at 20:14

1 Answer 1

1

MySQL connector for java works for Kotlin as well. You can download it from https://dev.mysql.com/downloads

And then you can kotlint like that:

val connectionProps = Properties()
connectionProps.put("user", username)
connectionProps.put("password", password)

try {
    Class.forName("com.mysql.jdbc.Driver").newInstance()
    conn = DriverManager.getConnection(“url”, connectionProps)
} catch (ex: SQLException) {
    // handle any errors
    ex.printStackTrace()
} catch (ex: Exception) {
    // handle any errors
    ex.printStackTrace()
}
Sign up to request clarification or add additional context in comments.

1 Comment

thank you i will learn jdbc i need to know more about that how create tables and how to insert and view .......

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.