MDAC 2.5 SDK - ADO


 

Using ADO with the Java Type Library Wizard

See Also

The Java Type Library Wizard is a feature of Visual J++ 1.x, integrated into the Tools menu of the development environment. Its purpose is to search a type library and create a Java interface that allows access to COM objects. For Visual J++ 6.0, the Java Type Library Wizard has been replaced with ADO for Windows Foundation Classes.

The Java Type Library Wizard produces similar results as the command-line tools included with the Microsoft SDK for Java. However, you cannot step into the class wrappers that the Wizard generates, unlike the class wrappers generated by the Microsoft SDK for Java.

The Java Type Library Wizard generates the classes in the following location: \<windows directory>\Java\trustlib\msado15.  The Summary.txt file, located in the directory where the classes were generated, shows the class definitions it generated.

The Java Type Library Wizard converts enumerated types, found in any given type library, to type INT (integer). It also defines an interface that corresponds to each enumerated type in the type library. You can reference the values of an ADO enumerated type with the following syntax:

msado15.<Enum Name>.<constant Name>

An example of this is shown in the following code fragment for setting the CommandType property of a Command object:

Cmd1.putCommandType( msado15.CommandTypeEnum.adCmdStoredProc );

Alternately, you could inherit from the enumerated type wrapper generated by the Java Type Library Wizard. If so, you could remove "msado15." from the syntax. However, your class would need to inherit from each Java object and enumerated type interface that it references to completely eliminate the need to reference msado15.* in front of all ADO objects and enumerated values.

For more sample code, see ADO Java Class Wrappers.

To run the Java Type Libary Wizard from Visual J++ version 1.x:

  1. From the Tools menu, select Java Type Library Wizard.

  2. Select "Microsoft ActiveX Data Objects Library" and click OK. This now (re)generates files in the \trustlib directory for ADO (by default at c:\winnt\java\trustlib\msado15). If you used the Microsoft SDK for Java to already generate classes for ADO, they will be replaced with those from the Java Type Library Wizard.

  3. To use these files, open your project in Visual J++. From the Project menu, choose Add To Project. Select Files, and add all of the .JAVA files generated in the \trustlib directory (by default at c:\winnt\java\trustlib\msado15) to your project.