0

I want to connect to ExaSol database using Scala. I'm able to connect to the database in Python using pyodbc but I'm receiving the following error on attempting to connect using JDBC driver in Scala :

scala> :require /Users/some/path/mssql-jdbc-7.4.0.jre8.jar
scala> Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver")
scala> import java.sql.{Connection, DriverManager, ResultSet}
scala> val conn = DriverManager.getConnection("jdbc:sqlserver://11.11.11.11:8563;databaseName=some-db;user=user_name;password=pass_word;useUnicode=true;characterEncoding=UTF-8")
Sep 11, 2019 1:38:55 PM com.microsoft.sqlserver.jdbc.SQLServerConnection Prelogin
WARNING: ConnectionID:2 ClientConnectionId: a03dede8-7f9c-495d-83d5-4986b859e1e9 Prelogin error: host 11.11.11.11 port 8563 Unexpected end of prelogin response after 0 bytes read
Sep 11, 2019 1:38:55 PM com.microsoft.sqlserver.jdbc.SQLServerConnection Prelogin
WARNING: ConnectionID:2 ClientConnectionId: ea705538-c0c9-4bc3-ba66-9630e7850b58 Prelogin error: host 11.11.11.11 port 8563 Unexpected end of prelogin response after 0 bytes read
Sep 11, 2019 1:39:09 PM com.microsoft.sqlserver.jdbc.SQLServerConnection Prelogin
WARNING: ConnectionID:2 ClientConnectionId: 5238ac7c-55cc-4ec2-a070-d7f454c6c43b Prelogin error: host 11.11.11.11 port 8563 Unexpected end of prelogin response after 0 bytes read
com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host 11.11.11.11, port 8563 has failed. Error: "The driver received an unexpected pre-login response. Verify the connection properties and check that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. This driver can be used only with SQL Server 2005 or later.". ClientConnectionId:5238ac7c-55cc-4ec2-a070-d7f454c6c43b
  at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:2924)
  at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:2913)
  at com.microsoft.sqlserver.jdbc.SQLServerConnection.Prelogin(SQLServerConnection.java:2655)
  at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:2480)
  at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:2142)
  at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:1993)
  at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:1164)
  at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:760)
  at java.sql.DriverManager.getConnection(DriverManager.java:664)
  at java.sql.DriverManager.getConnection(DriverManager.java:270)
  ... 28 elided
Gord Thompson
  • 116,920
  • 32
  • 215
  • 418
SpaceMonkey
  • 25
  • 1
  • 4
  • Which ODBC driver are you using when you connect via pyodbc? – Gord Thompson Sep 11 '19 at 12:19
  • @GordThompson - I think it is - EXASolution_ODBC-5.0.18 – SpaceMonkey Sep 11 '19 at 12:35
  • So what led you to believe that you could connect to Exasol using the JDBC driver for Microsoft SQL Server? – Gord Thompson Sep 11 '19 at 12:40
  • @GordThompson - This is the result I got when I searched for Scala ODBC driver - https://gist.github.com/curt-labs/3370383 . I know it's using a Microsoft driver but that's the best I found through Google. – SpaceMonkey Sep 11 '19 at 12:56
  • Fair enough, but the JDBC driver you need depends on the database you're connecting *to*, not the language you're connecting *from*. Try modifying your code to use the Exasol JDBC driver. – Gord Thompson Sep 11 '19 at 13:22

1 Answers1

1

Please try to use the "com.exasol.jdbc.EXADriver" driver.

The documentation is in the below url:

https://docs.exasol.com/connect_exasol/drivers/jdbc.htm

partha_devArch
  • 414
  • 2
  • 10