Arne Vajhøj
2024-08-27 00:44:32 UTC
Reply
Permalink1) enable SQLServer authentication (Windows authentication only will not
work)
2) download official Microsoft JDBC driver and transfer it to VMS
3) make sure TCP port 1433 is open in various firewalls
And voila - access from Java, Groovy, Kotlin, Scala and more
exotic JVM languages.
Demo with Groovy:
$ type mssql.groovy
import java.sql.*
con =
DriverManager.getConnection("jdbc:sqlserver://arnepc5;database=Test;integratedSecurity=false;encrypt=false;",
"sa", "hemmeligt
")
pstmt = con.prepareStatement("SELECT f1, f2 FROM t1")
rs = pstmt.executeQuery()
while(rs.next()) {
f1 = rs.getInt(1)
f2 = rs.getString(2)
printf("%d %s\n", f1, f2)
}
con.close()
$ groovy_cp = "mssql-jdbc-12_2_0_jre8.jar"
$ groovy mssql.groovy
1 A
2 BB
3 CCC
And if JDBC is too low level then JPA can be used (Hibernate
works fine as JPA provider on VMS - and it does come with
SQLServer dialect).
Easy.
One of the finer points is that the Microsoft JDBC driver
is type 4 for SQLServer authentication and therefore can run
on VMS (it is type 2 for Windows autehntication, but that does
not matter).
So no need for jTDS JDBC driver.
Arne