Hello Ranchers. I have an application that executes a SQL query using JDBC and the jTDS driver. It then stores the results of the query in a two-dimensional string array and closes the connections:
When I do another search with different search criteria, everything seems to work fine. However, if I do the exact same search a second time, the array of results seems to hold onto the previous data. I'd imagine that I may need to destroy the existing array somehow, though I thought that re-instantiating serves the same purpose. Does anyone know what could be causing this? Thanks! [ May 14, 2007: Message edited by: Scott Florez ]
If you are doing the exact same search a second time, shouldn't the results be identical?
No, because the database is updatable and is accessed my multiple users simultaneously. So on a large search, there's a decent chance something may have changed since the previous search. Plus, I don't use "order by" in my SQL query, so the results will come back in a different order every time. [ May 14, 2007: Message edited by: Scott Florez ]
No, because the database is updatable and is accessed my multiple users simultaneously. So on a large search, there's a decent chance something may have changed since the previous search.
A "decent chance"? Has it actually been updated?
Joined: Dec 05, 2006
After playing with my application some more, I don't think I originally described my problem properly, so let me try again.
My application does SQL queries using the code I posted above and displays a summary of the results in a summary screen with the ability to iterate through the records 25 at a time (which are stored in a 2D string array). Then, the user can select a record's summary and click a button to view its details (which are selected from the array using it's index number).
Upon the first search, everything works properly. Upon a second search, everything works until the user clicks the details button. Then, a totally different (and seemingly random) record is displayed instead of the one the user wanted to view. Restarting the application will always allow the same search to work properly the first time, but then subsequent searches fail.
I know the right index number is being referenced when the user selects the details. It's as if the data in the array are shifting around somehow.
Let me know if you'd like to see any additional code. Thanks everyone. [ May 14, 2007: Message edited by: Scott Florez ]
It would help to if you can provide some additional code. With the code provided i guess some variable is not getting initialized properly. Does this method also references any instance/class variables.