Connecting to MSSQL from SCALA/Play using jTds

  • use jTds driver and
  • Check the java version if it hangs at getConnection() statement.

http://stackoverflow.com/questions/6943553/list-of-jdbc-drivers-for-sql-server-2008-comparison

-http://karthicraghupathi.com/2013/12/16/squirrel-sql-jtds-and-windows-authentication-sso-for-microsoft-sql-server/

	val driver = "net.sourceforge.jtds.jdbc.Driver"
 	val url = "jdbc:jtds:sqlserver://server/db_name;instance=instance_name;"
    val username = "user"
    val password = "pass"

    var connection:Connection = null
    try{
    	Class.forName(driver)
 
    connection = DriverManager.getConnection(url, username, password)
    	val query = "select *from tbl"
    	
    	val statement = connection.createStatement()
    	val resultSet = statement.executeQuery(query)
    	println(resultSet)
    	
    	
    	while( resultSet.next() ){
    		val host = resultSet.getString("RAM_ID")
    		println("host: "+host)
    	}
    	
    }catch{
    	case e => e.printStackTrace
    }
    
    connection.close()