Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Azure sql server connection issue #580

Closed
kmbb184 opened this issue Jun 13, 2019 · 1 comment
Closed

Azure sql server connection issue #580

kmbb184 opened this issue Jun 13, 2019 · 1 comment

Comments

@kmbb184
Copy link

kmbb184 commented Jun 13, 2019

I'm trying to connect to Azure SQL database (using Microsoft SQL server jdbc).
I can get working connection with java.sql.DriverManager:
conn = DriverManager.getConnection(dbFullAddress, dbUser, dbPassword)

However, trying to connect using Exposed results in "Connection closed":

The connection is closed.
com.microsoft.sqlserver.jdbc.SQLServerException: The connection is closed.
  at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:234)
  at com.microsoft.sqlserver.jdbc.SQLServerDatabaseMetaData.checkClosed(SQLServerDatabaseMetaData.java:172)
  at com.microsoft.sqlserver.jdbc.SQLServerDatabaseMetaData.getURL(SQLServerDatabaseMetaData.java:1442)
  at org.jetbrains.exposed.sql.Database$url$2.invoke(Database.kt:27)
  at org.jetbrains.exposed.sql.Database$url$2.invoke(Database.kt:16)
  at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
  at org.jetbrains.exposed.sql.Database.getUrl(Database.kt)
  at org.jetbrains.exposed.sql.Database$dialect$2.invoke(Database.kt:30)
  at org.jetbrains.exposed.sql.Database$dialect$2.invoke(Database.kt:16)
  at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
  at org.jetbrains.exposed.sql.Database.getDialect(Database.kt)
.......
implementation("com.microsoft.sqlserver:mssql-jdbc:7.2.2.jre8")
implementation("org.jetbrains.exposed:exposed:0.14.3")

private val dbUser = "user"
private val dbPassword ="password"
private val dbFullAddress = "jdbc:sqlserver://db-prefix.database.windows.net:1433;databaseName=dbname;authentication=SqlPassword" 

private var db : Database

init {
    val db = Database.connect(dbFullAddress, "com.microsoft.sqlserver.jdbc.SQLServerDriver",
            user = dbUser, password = dbPassword)
    print(db.name)
}

I tried different combinations of "authentication" parameter but nothing worked/
I use openjdk:
OpenJDK Runtime Environment (build 1.8.0_212-8u212-b03-0ubuntu1.18.04.1-b03)
OpenJDK 64-Bit Server VM (build 25.212-b03, mixed mode)

@Tapac
Copy link
Contributor

Tapac commented Jun 13, 2019

Please check Exposed 0.14.4

@Tapac Tapac closed this as completed Jun 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants