Link to home
Start Free TrialLog in
Avatar of ckoster
ckoster

asked on

Variant class and ADO.Recordset.getRows()

Hello All,

I'm a newbie to Java/J++ and I'm writing a data access wrapper to
encapsulate ADO functionality.  I have a function
that takes a SQL statement and returns a two dimenisional variant array
representing the SQL resultset.  I am trying to
use the ADO.Recordset.getRows() function and it seems to work.

The problem is, how the heck to I get the information out of the Variant
object I have created?  In VB I just used the
variant array like such:  target =  vArray(2,1) but I can't figure out how
to do this in J++.

Here is what my code looks like...

import com.ms.com.*;

file://Private member variables
 private Variant mvRecords = null;

public Variant getVariantArrayFromSQL(String sSQL)
  {
   Recordset rst = new Recordset();
   Connection con = new Connection();

   con.setConnectionString(msConnectString);
   con.open();

   rst.setActiveConnection(con);
   rst.setCursorLocation(AdoEnums.CursorLocation.CLIENT);
   rst.setCursorType(AdoEnums.CursorType.KEYSET);
   rst.open(sSQL);

   mvRecords = rst.getRows();
   return mvRecords;
  }

...again, this function seems to work (I get no errors and the array seems
to be returned correctly to the calling client) but I can't figure out how
to use
the mvRecords object to get the data out of it!!!   There are a bunch of
methods like .getBoolean and .getInteger but they're not working for me and
I can't
find anything in the help or on MSDN that shows me how to use this object.

Any help would be much appreciated.

Thanks,

Craig


ASKER CERTIFIED SOLUTION
Avatar of Jod
Jod

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ckoster
ckoster

ASKER

Thanks, Jod.  I dumped the resultset to the safearray and everything worked great.

Re:  your comments about J++...I am just learning java and I'm using J++ as the tool to learn and it does make me a little concerned about the "purity" of the java language.  I know you can disable the Microsoft Java Extensions in the J++ IDE.  Would you suggest doing this to help me learn the non-MS version of Java?

I also have a copy of Borland's JBuilder sitting around.  Do you think that would be a better learning tool for me to get a grasp of what "real" Java is about.

Any advice would be much appreciated.

Thanks,

Craig
I'm not usually one to get worried about this sort of thing - using the right tools for the right job is my motto.

But I have to say that the code above is so different to anything available in standard Java that what you are really learning is not how to program in Java but how to program J++.

This knowledge will be no good to you if you have to access databses using Java's own database drivers, which use the JDBC standard.

JBuilder is quite highly rated and will give you a better feel for how Java really works. Visual Age for Java and Visual Cafe are also very good.

Personally I currently have to use a text editor (Programmers File Editor) and the sun JDK which is unfortunately due to the OS I am working on. No better way to learn though...