Hello there. OK this problem is doing my head in and I keep on encountering it whilst programming. In this particular case there are two classes involved...Rectangle and OMGraphicList. In the Rectangle class I execute a call to my database using
JDBC and insert the results of my SQL statement into a simple vector object. This works fine. Below is a brief code snippet from the Rectangle class:
public class Rectangle
{
protected Vector idQueryVector = new Vector();
...
public void makeQuery(
String query)
{
...
try
{
Connection cont = new Connection();
Statement stmt = cont.conn.createStatement();
OracleResultSet ors = (OracleResultSet)stmt.executeQuery(query);
while(ors.next())
{
String dbObject = (String) ors.getObject(1);
idQueryVector.add(dbObject);
}
System.out.println(idQueryVector.size()); //returns non-zero value
ors.close();
cont.conn.close();
}
catch(Exception sqlE){}
In the OMGraphicList class I also have populated a vector called idVector with values. I can output the vector elements without any trouble. What I need to do is to compare the values in this idVector and the idQueryVector from the Rectangle class. I try to do this in the OMGraphicList class by calling an instance of the Rectangle class as follows:
Rectangle rect = new Rectangle();
However when I execute the following print statement it returns 0 indicating that the idQueryVector is empty whereas it is not empty
System.out.println(rect.idQueryVector.size()); //returns zero
What am I doing wrong here. Do I need to put all the functionality in the one class in order to get it to execute. Cheers Joe