In this example, the
IOM driver is used to return the number of observations stored in
the SASHELP shoes SAS data set.
import java.sql.*;
import java.util.Properties;
public class SSPIAuthentication
{
public static void main(String argv[])
{
Connection connection;
Properties props;
Statement statement;
String queryString = "SELECT COUNT(*) " +
"FROM sashelp.shoes";
ResultSet result;
double rowcount;
try {
//CONNECT TO THE SERVER BY USING A CONNECTION PROPERTY LIST
Class.forName("com.sas.rio.MVADriver");
props = new Properties();
props.setProperty("usesspi","negotiate");
/*
* properties user and password are not specified because
* SSPI is providing the identity to the workspace server
*/
connection = DriverManager.getConnection(
"jdbc:sasiom://c123.na.abc.com:8591", props);
//ACCESS DATA
statement = connection.createStatement();
result = statement.executeQuery(queryString);
while (result.next()){
rowcount = result.getDouble(1);
System.out.println("Number of obs in sashelp.shoes: " + rowcount);
}
statement.close();
connection.close();
}
catch(Exception e){
System.out.println("error " + e);
}
}
}