*
The moose likes JDBC and the fly likes Woes with ResultSets and Arrays Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » JDBC
Bookmark "Woes with ResultSets and Arrays" Watch "Woes with ResultSets and Arrays" New topic
Author

Woes with ResultSets and Arrays

Alan Watts
Greenhorn

Joined: May 14, 2001
Posts: 28
HI there,
I am using JDBC to interrogate an Access DB with the goal of retrieving the data in one column of the DB as a java.sql.Array Array object, and then casting that Array object into an array of int, before assigning it to a variable (called "currentbid").
This ain't a trivial syntax etc error, as the code compiles fine, and runs up until the commented statement. I suspect the connection object might be interfering, although it has been tested and is working OK independently.
Any help gratefully appreciated
Alan Watts
I am having trouble executing the following block of statements:
Note that "con" is the database connection variable.
PreparedStatement pstmt1 = con.prepareStatement("SELECT Amount FROM Bids WHERE Spec = 200011;");
ResultSet r = pstmt1.executeQuery();
while (r.next()) {
Array currentbidarray = r.getArray("Amount");//This is the problem block.
int [] currentbid = (int [])currentbidarray.getArray();
return;
}
Alan Watts
Greenhorn

Joined: May 14, 2001
Posts: 28

PS. The following SQL Exception is being generated. Does this mean that this is a driver-related problem?
-----------------------
java.sql.SQLException: SQL 3 Data types are not supported
at easysoft.sql.jobResultSet.getArray(UnknownSource)
...
-----------------------
Alan Watts
Greenhorn

Joined: May 14, 2001
Posts: 28
OK people,
No need for anyone to respond on this topic, as I have solved the problem. If you are interested, the problem occurred because my commercial JDBC driver does not support the JDBC 2.0 API (but rather is still at JDBC 1.2). In other words, it cannot support advanced data types such as Array objects.
Alan
 
GeeCON Prague 2014
 
subject: Woes with ResultSets and Arrays