'Android Studio creating MSSQL Connection
i started programming in kotlin a month ago and got interested in SQL Databases. I created Apps with Firebase but now im looking for an alternative way without extern sources. I want to use the MSSQL Database on my own server with JDBC but i get an java.lang error. Can someone help me to correct the Code or show an alternative way to JDBC?
I placed Logs to test, where i get the mistake. I tried write something into the Database. I Created the object and the function and get this error:
object user: Table("benutzer") {
val id: Column<Int> = integer("ID")
val name: Column<String> = varchar("name", 255)
val passwort: Column<String> = varchar("passwort", 255)
override val primaryKey = PrimaryKey(id, name = "PK_Benutzer_Id")
}
fun database () {
Log.e("Funktion: ", "Start")
Database.connect("jdbc:sqlserver://<serverIP>:<port>;database=<databasename>", "com.microsoft.sqlserver.jdbc.SQLServerDriver", "<username>", "<password>")
Log.e("Funktion: ", "Database connect URL durchgeführt")
transaction {
Log.e("Funktion: ", "Transaction")
addLogger(StdOutSqlLogger)
Log.e("Funktion: ", "addLogger")
val id = user.insert {
it[name] = "benutzer"
}
Log.e("Funktion", "Tabelle befüllt")
}
}
2022-05-16 15:23:06.790 7272-7441/com.example.testsql E/Funktion:: addLogger
2022-05-16 15:23:07.008 7272-7272/com.example.testsql E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.testsql, PID: 7272
java.lang.NoSuchMethodError: No virtual method supportedOptions()Ljava/util/Set; in class Ljava/net/Socket; or its super classes (declaration of 'java.net.Socket' appears in /apex/com.android.art/javalib/core-oj.jar)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
