ADO Java Class Wrappers

Microsoft ActiveX Data Objects (ADO)

ADO 2.5 Appendixes

ADO Java Class Wrappers

This code declares an instance of the ADO Recordset class wrapper and initializes it, all on the same line of code. Further, it declares variables for each of the arguments in the Open method, especially for LockType and CursorType (because Java doesn't support enumerated types). It opens and closes the Recordset object. Setting Rs1 to NULL merely schedules that variable to be released when Java performs its systematic and intermittent release of unused objects.

public static void main( String args[])
{
   msado15._Recordset   Rs1 = new msado15.Recordset();
   Variant Source     = new Variant( "SELECT * FROM Authors" );
   Variant Connect    = new Variant( "DSN=AdoDemo;UID=admin;PWD=;" );
   int     LockType   = msado15.CursorTypeEnum.adOpenForwardOnly;
   int     CursorType = msado15.LockTypeEnum.adLockReadOnly;
   int     Options    = -1;

   Rs1.Open( Source, Connect, LockType,  CursorType, Options );
   Rs1.Close();
   Rs1 = null;

   System.out.println( "Success!\n" );
}

See Also

Using ADO with the Java Type Library Wizard | Using ADO with the Microsoft SDK for Java

© 1998-2003 Microsoft Corporation. All rights reserved.