Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Q: java.sql.ResultSet && NSTableView.DataSource?

Q: java.sql.ResultSet && NSTableView.DataSource?
Thread Tools
Junior Member
Join Date: Sep 2000
Location: Washington State
Status: Offline
Reply With Quote
Apr 24, 2001, 01:34 PM
 
I am trying to build a Cocoa/Java app that takes results of a SQL Query and inserts them into an NSTableView.

As I understand it, I need to specify an object that implements the NSTableView.DataSource interface. Fine. I would like to extend the standard ResultSet to do this, however I cannot figure out how to accomplish this. ResultSet seems to be an interface as well. If it is instantiated, it must be implemented in some class, right?

Anyhow, any help would be appreciated. This is my first real Cocoa/Java project of any complexity. If anyone can point me to code samples or anything, that would be great.

Mr. Sharumpe
     
Junior Member
Join Date: Nov 2000
Status: Offline
Reply With Quote
May 8, 2001, 11:00 PM
 
I'm actually working on the same thing in Cocoa using the java bridge to access the database via some java utility classes. I was wondering if yo uwould be open to a collaborative process.

feel free to email me directly at mxcantor@sas.upenn.edu
     
Fresh-Faced Recruit
Join Date: Mar 2001
Location: Dixon, Ca
Status: Offline
Reply With Quote
May 9, 2001, 02:03 AM
 
sharumpe,

A JDBC driver returns the driver vendors implementation of the ResultSet interface. A simple example would be when an application calls Statement.executeQuery("SELECT * FROM SOMETABLE"). The call to executeQuery is guaranteed to return either a ResultSet or to throw an exception. Using ResultSet.next() and the various getXXXX() methods you can iterate through the rows and columns and insert the data into your NSTableView. It's not exactly clear to me what your intent is, but I don't think you want to extend ResultSet when the JDBC driver is already returning you an object which has fully implemented the ResultSet interface.

I recently finished a project implementing a JDBC driver for accessing IBM DB2 databases. If you want to email me with more specific questions I'd be happy to try and answer them.

Bob
So they cloned a sheep - who could tell the difference anyway? - Robin Williams
     
Junior Member
Join Date: Sep 2000
Location: Washington State
Status: Offline
Reply With Quote
May 9, 2001, 10:39 AM
 
Originally posted by gandalf:
It's not exactly clear to me what your intent is, but I don't think you want to extend ResultSet when the JDBC driver is already returning you an object which has fully implemented the ResultSet interface.
I was hoping to be able to extend ResultSet to implement the NSTableView.DataSource interface. In other words, the ResultSet needs to respond to messages that tell the NSTableView how to display its data.

I have created an object that does the job, but it means duplicating data, and I don't like that. Also, a future possibility for the project is to allow the user to change the data. If I remember correctly, JDBC 2 has methods that allow ResultSet data to be updated by simply changing the data in the ResultSet and issuing an update message.

Anyhow, the whole thing would be cleaner if the data returned from the SQL query only existed in one spot.

I think I will explore extending the driver-specific ResultSet (OracleResultSet, in this case) to do what I need.

Thanks!
Mr. Sharumpe
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 01:26 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2