// 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.*;
import java.text.*;

public class USPDT {
    public static void main(String[] args) throws Exception {
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
        Connection con = DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost;DatabaseName=Test", "sa", "");
        con.setCatalog("Test");
        CallableStatement cstmt = con.prepareCall("{CALL uspdt(?,?)}");
        cstmt.setDate(1, new Date(df.parse("2005-10-01").getTime()));
        cstmt.setDate(2, new Date(df.parse("2005-10-31").getTime()));
        cstmt.execute();
        ResultSet rs = cstmt.getResultSet();
        if(rs.next()) {
            System.out.println(rs.getBigDecimal(1));
        }
        cstmt.close();
        con.close();
    }
}
