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.
1 Answer
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()
}
1 Comment
abdo
thank you i will learn jdbc i need to know more about that how create tables and how to insert and view .......