| | |
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 |
-xlint android api applet application array arrays automation bi binary blackberry block bluetooth chat class client code compile compiler component database developmenthelp digit eclipse error fractal freeze functiontesting game gameprogramming givemetehcodez graphics gui health html hyper ide image int integer j2me j2seprojects java javac javaprojects jetbrains jni jpanel jtable julia learningresources lego linux list login loops mac main map method methods mobile myregfun netbeans newbie nonstatic notdisplaying number online pearl problem program programming project qt recursion scanner screen server set singleton sms sort spamblocker sql string swing system textfields thread threads time title tree tutorial-sample update variablebinding windows working xor






