// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class MSSQLServer {
    public static void main(String[] args) throws Exception {
        // not necesarry
        //Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
        // not working properly even with -Djava.library.path=C:\DivJava\sqljdbc_2.0\enu\auth\x86\sqljdbc_auth.dll
        //Connection con = DriverManager.getConnection("jdbc:sqlserver://localhost;DatabaseName=Test;IntegratedSecurity=true");
        Connection con = DriverManager.getConnection("jdbc:sqlserver://localhost;DatabaseName=Test", "xxxx", "xxxx");
        Statement stmt = con.createStatement();
        ResultSet rs = stmt.executeQuery("SELECT * FROM t1");
        while(rs.next()) {
            System.out.println(rs.getInt(1) + " "  + rs.getString(2));
        }
        rs.close();
        stmt.close();
        con.close();
    }
}
