Created
August 16, 2012 14:12
-
-
Save curt-labs/3370383 to your computer and use it in GitHub Desktop.
Scala ODBC Connection to SQL Server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.