Skip to content

Instantly share code, notes, and snippets.

@curt-labs
Created August 16, 2012 14:12
Show Gist options
  • Save curt-labs/3370383 to your computer and use it in GitHub Desktop.
Save curt-labs/3370383 to your computer and use it in GitHub Desktop.
Scala ODBC Connection to SQL Server
import java.sql.{Connection, DriverManager, ResultSet}
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver")
val conn = DriverManager.getConnection("jdbc:sqlserver://216.17.90.83;databaseName=CurtDev;user=*******;password=XXXXXX;useUnicode=true;characterEncoding=UTF-8")
try {
val statement = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY)
val rs = statement.executeQuery("select * from Part")
while(rs.next()) {
println(rs.getInt("partID"))
}
}catch {
case e => e.printStackTrace()
}finally {
conn.close()
}
@alkanschtein
Copy link

it seems like jdbc not odbc am I missing something?
But thank you for your effort. I am still trying to connect IDK why there is an issue in my connection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment