| | |
JDBC not recognizing ResultSet assingment (?)
Thread Solved |
•
•
Join Date: Nov 2008
Posts: 63
Reputation:
Solved Threads: 4
Hello all,
I have used this code throughout this application with no troubles. I am creating a datatable, and the data is a result set returned from a sql query to an oracle 11g database. I'm creating a TableModel class that overrides the AbstractTableModel so I can add fetures to it. I get errors when I try to assign my ResultSet object however. Here is the code:
I have no idea why this is not recognizing an object that was created in the line of code right above it, or why rs will auto complete with the expected methods and members but java can't find the package it belongs to.
rs hasn't been declared elsewhere. (It would throw a different error if it had). Any ideas?
I have used this code throughout this application with no troubles. I am creating a datatable, and the data is a result set returned from a sql query to an oracle 11g database. I'm creating a TableModel class that overrides the AbstractTableModel so I can add fetures to it. I get errors when I try to assign my ResultSet object however. Here is the code:
Java Syntax (Toggle Plain Text)
class MyTableModel extends AbstractTableModel { Statement stmt = conn.createStatement(); ResultSet rs; // the following throws compilation error: "cannot find symbol, symbol: class rs, location class <where it resides in my app> <identifier exepected> rs = stmt.executeQuery(query); //the following is fine: ResultSetMetaData rsmd = rs.getMetaData(); int numcols = rsmd.getColumnCount(); int numrows; int i = 0; int k = 0; //rs.next throws the same error as above while (rs.next()) { for (k = 0; k <= numcols; k++) { data[i][k] = rs.getString(k); } if (checked) { data[i][k + 1] = new Boolean(false); } i++; } //Default Table Model overrides follow.
I have no idea why this is not recognizing an object that was created in the line of code right above it, or why rs will auto complete with the expected methods and members but java can't find the package it belongs to.
rs hasn't been declared elsewhere. (It would throw a different error if it had). Any ideas?
•
•
Join Date: Nov 2008
Posts: 63
Reputation:
Solved Threads: 4
0
#4 Oct 21st, 2009
HA! I copied that code directly from the sun site. The JDBC / SQL stuff was mine (Although copied from another source initially). I'm not sure however, but the boolean value is meant to represent a checkbox in a Jtable that displays the sql data (I am adding a selection checkbox to the end.) The boolean value needs toreturn its type from a call to getColumnClass() I've overriden. Could that why the created it as an object? Traditinally, there is no such thing as a native "boolean" type.
0
#5 Oct 21st, 2009
> Could that why the created it as an object?
There is absolutely no valid reason as to why a Boolean object needs to be created if one already exists and is ready to use i.e. considering that a Boolean can have only two states: TRUE and FALSE and those two are already accounted by the public static fields TRUE and FALSE of the Boolean class.
> Traditinally, there is no such thing as a native "boolean" type.
There is a primitive type "boolean". The usage of the primitive wrapper type Boolean v/s the primitive type boolean boils down to the use case in consideration i.e. whether you have an array of primitives or an array of reference types.
There is absolutely no valid reason as to why a Boolean object needs to be created if one already exists and is ready to use i.e. considering that a Boolean can have only two states: TRUE and FALSE and those two are already accounted by the public static fields TRUE and FALSE of the Boolean class.
> Traditinally, there is no such thing as a native "boolean" type.
There is a primitive type "boolean". The usage of the primitive wrapper type Boolean v/s the primitive type boolean boils down to the use case in consideration i.e. whether you have an array of primitives or an array of reference types.
I don't accept change; I don't deserve to live.
![]() |
Similar Threads
- populate a template based on records in a JDBC ResultSet instance (Java)
- using jdbc-odbc driver (Java)
- somthing wrong about using JDBC-ODBC (JSP)
- ResultSet.... getterMethod() (Java)
- help with JDBC oracle9i (Java)
- resultset updatable (Oracle)
- jdbc help? (Java)
- Java JDBC ResultSet (Java)
Other Threads in the Java Forum
- Previous Thread: Run a function automatically
- Next Thread: hibarnate Bi-directional associations
| Thread Tools | Search this Thread |
android api applet application apps array arrays automation awt bidirectional binary birt bluetooth businessintelligence busy_handler(null) card chat class classes client code collision columns component constructor crashcourse database designadrawingapplicationusingjavajslider draw eclipse error errors eventlistener exception expand fractal game givemetehcodez graphics gui guidancer html ide image inetaddress integer intellij j2me java javadoc javafx javamicroeditionuseofmotionsensor javaprojects jme jni jpanel jtree julia linux list loop machine map method methods mobile mobiledevelopmentcreatejar myaggfun netbeans newbie oracle plazmic print problem program programming project radio recursion scanner server set sharepoint smart sms smsspam sort sortedmaps sql string subclass support swing textfield threads tree unlimited utility webservices windows






