Help with streaming result sets and prepared statements

hi all
I create a callable statement that is capable of streaming.
statement = myConn2.prepareCall("{call graphProc(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)}",java.sql.ResultSet.TYPE_FORWARD_ONLY,
java.sql.ResultSet.CONCUR_READ_ONLY);
statementOne.setFetchSize(Integer.MIN_VALUE);
the class that contains the query is instantiated 6 times the first class streams the results beautifully and then when the second
rs = DatabaseConnect.statementOne.executeQuery();
is executed I get the following error
java.sql.SQLException: Can not use streaming results with multiple result statements
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:910)
at com.mysql.jdbc.MysqlIO.readAllResults(MysqlIO.java:1370)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1688)
at com.mysql.jdbc.Connection.execSQL(Connection.java:3031)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:943)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1049)
at com.mysql.jdbc.CallableStatement.executeQuery(CallableStatement.java:589)
the 6 instances are not threaded and the result set is closed before the next query executes is there a solution to this problem it would be greatly appreciated
thanks a lot
Brian

Database resources should have the narrowed scope
possible. I don't think it's a good idea to use a
ResultSet in a UI to generate a graph. Load the data
into an object or data structure inside the method
that's doing the query and close the ResultSet in a
finally block. Use the data structure to generate
the graph.
It's an example of MVC and layering.
Ok that is my bad for not elaborating on the finer points sorry, the results are not directly streamed into the graphs from the result set. and are processed in another object and then plotted from there.
with regards to your statement in the beginning I would like to ask if you think it at least a viable option to create six connections. with that said would you be able to give estimated users using the six connections under full usage.
just a few thoughts that I want to
bounce off you if you don't mind. Closing the
statement would defeat the object of of having a
callable statement How so? I don't agree with that.
%again I apologise I assumed that since callable statements inherit from prepared statements that they would have the pre compiled sql statement functionality of prepared statements,well If you consider in the example I'm about to give maybe you will see my point at least with regards to this.
The statement that I create uses a connection and is created statically at the start of the program, every time I make a call the same statement and thus connection is used, creating a new connection each time takes up time and resources. and as you know every second counts
thanks for your thoughts
Brian.

Similar Messages

  • Help with calling stored procedure and preparing statement

    hi guys help please..I want to call a procedure set the ResultSet to TYPE_SCROLL_INSENSITIVE and CONCUR_UPDATABLE in order for me to scroll thru the resultset from 1st row to end row and vice-versa..but currently, my code has an error becuase im hot sure on how to do this..Can you please help me guys to solve this? Thanks in advance!
    CODE:
                int c = 0;
                String searchArg = txtSearch.getText();
                String studName, mInitial;
                searchArg = searchArg.replace('*', '%');           
                con = FuncCreateDBConnection();
                con.prepareCall("{call dbsample.usp_StudentInfo_SEARCH(?, ?)}");
                *cStmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);*
                cStmt.setString("searchArg", searchArg);
                cStmt.setString("searchType", cmboSearchBy.getSelectedItem().toString());           
                rs = cStmt.executeQuery();           
                if (rs != null){
                    listModel = new DefaultListModel();           
                    lstSearchResult.setModel(listModel);
                    while (rs.next()){                                      
                          mInitial = rs.getString(4).substring(0, 1).toUpperCase();
                          studName = rs.getString(3) + ", " + rs.getString(2) + " " + mInitial + ".";                     
                          listModel.addElement(studName);
                    System.out.println("Rows:"+ rs.getString(2));                                                     
                          c++;
    ERROR:
    Incompatible Types
    Found : java.sql.Statement
    Required: java.sql.CallableStatement

    Nevermind guys..i got it..
    CODE:
                int c = 0;
                String searchArg = txtSearch.getText();
                String studName, mInitial;
                searchArg = searchArg.replace('*', '%');           
                con = FuncCreateDBConnection();           
                cStmt = con.prepareCall("{call dbsample.usp_StudentInfo_SEARCH(?, ?)}",ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
                cStmt.setString("searchArg", searchArg);
                cStmt.setString("searchType", cmboSearchBy.getSelectedItem().toString());           
                rs = cStmt.executeQuery();           
                if (rs != null){
                    listModel = new DefaultListModel();           
                    lstSearchResult.setModel(listModel);
                    while (rs.next()){                                      
                          mInitial = rs.getString(4).substring(0, 1).toUpperCase();
                          studName = rs.getString(3) + ", " + rs.getString(2) + " " + mInitial + ".";                     
                          listModel.addElement(studName);
                    System.out.println("Rows:"+ rs.getString(2));                                                     
                          c++;
                }     Edited by: daimous on Jan 31, 2008 6:04 PM

  • Calling a Stored Procedure with a result set and returned parms

    I am calling a stored procedure from a Brio report. The stored procedure returns a result set, but also passes back some parameters. I am getting a message that states that the DBMS cannot find the SP with the same footprint. Besides the result set, the SP returns 3 out parameters: (Integer, char(60), char(40)). Is there something special I need to do in Brio to format the out parameters to be passed back from the SP.
    Thanks,
    Roland

    Did you try just declaring the vars?
    untested
    declare
      myCur SYS_REFCURSOR;
      myRaw RAW(4);
      BEGIN
        test (0, 0, myRaw, sysdate, myCur);
      END;

  • Why to need close the result set and statement

    why to need close the result set and statement

    It's best to explicitly close every ResultSet, Statement, and Connection in the narrowest scope possible.
    These should be closed in a finally block.
    Since each close() method throws SQLException, each one should be in an individual try/catch block to ensure that a failure to close one won't ruin the chances for all the others.
    You can capture this in one nice utility class, like this:
    package db;
    import java.sql.*;
    import java.util.ArrayList;
    import java.util.Map;
    import java.util.LinkedHashMap;
    import java.util.List;
    import org.apache.commons.logging.Log;
    import org.apache.commons.logging.LogFactory;
    * Created by IntelliJ IDEA.
    * User: MD87020
    * Date: Feb 16, 2005
    * Time: 8:42:19 PM
    * To change this template use File | Settings | File Templates.
    public class DatabaseUtils
         * Logger for DatabaseUtils
        private static final Log logger = LogFactory.getLog(DatabaseUtils.class);
        /** Private default ctor to prevent subclassing and instantiation */
        private DatabaseUtils() {}
         * Close a connection
         * @param connection to close
        public static void close(Connection connection)
            try
                if ((connection != null) && !connection.isClosed())
                    connection.close();
            catch (SQLException e)
                logger.error("Could not close connection", e);
         * Close a statement
         * @param statement to close
        public static void close(Statement statement)
            try
                if (statement != null)
                    statement.close();
            catch (SQLException e)
                logger.error("Could not close statement", e);
         * Close a result set
         * @param rs to close
        public static void close(ResultSet rs)
            try
                if (rs != null)
                    rs.close();
            catch (SQLException e)
                logger.error("Could not close result set", e);
         * Close both a connection and statement
         * @param connection to close
         * @param statement to close
        public static void close(Connection connection, Statement statement)
            close(statement);
            close(connection);
         * Close a connection, statement, and result set
         * @param connection to close
         * @param statement to close
         * @param rs to close
        public static void close(Connection connection,
                                 Statement statement,
                                 ResultSet rs)
            close(rs);
            close(statement);
            close(connection);
         * Helper method that maps a ResultSet into a map of columns
         * @param rs ResultSet
         * @return map of lists, one per column, with column name as the key
         * @throws SQLException if the connection fails
        public static final Map toMap(ResultSet rs) throws SQLException
            List wantedColumnNames = getColumnNames(rs);
            return toMap(rs, wantedColumnNames);
         * Helper method that maps a ResultSet into a map of column lists
         * @param rs ResultSet
         * @param wantedColumnNames of columns names to include in the result map
         * @return map of lists, one per column, with column name as the key
         * @throws SQLException if the connection fails
        public static final Map toMap(ResultSet rs, List wantedColumnNames)
            throws SQLException
            // Set up the map of columns
            int numWantedColumns    = wantedColumnNames.size();
            Map columns             = new LinkedHashMap(numWantedColumns);
            for (int i = 0; i < numWantedColumns; ++i)
                List columnValues   = new ArrayList();
                columns.put(wantedColumnNames.get(i), columnValues);
            while (rs.next())
                for (int i = 0; i < numWantedColumns; ++i)
                    String columnName   = (String)wantedColumnNames.get(i);
                    Object value        = rs.getObject(columnName);
                    List columnValues   = (List)columns.get(columnName);
                    columnValues.add(value);
                    columns.put(columnName, columnValues);
            return columns;
         * Helper method that converts a ResultSet into a list of maps, one per row
         * @param rs ResultSet
         * @return list of maps, one per row, with column name as the key
         * @throws SQLException if the connection fails
        public static final List toList(ResultSet rs) throws SQLException
            List wantedColumnNames  = getColumnNames(rs);
            return toList(rs, wantedColumnNames);
         * Helper method that maps a ResultSet into a list of maps, one per row
         * @param rs ResultSet
         * @param wantedColumnNames of columns names to include in the result map
         * @return list of maps, one per column row, with column names as keys
         * @throws SQLException if the connection fails
        public static final List toList(ResultSet rs, List wantedColumnNames)
            throws SQLException
            List rows = new ArrayList();
            int numWantedColumns = wantedColumnNames.size();
            while (rs.next())
                Map row = new LinkedHashMap();
                for (int i = 0; i < numWantedColumns; ++i)
                    String columnName   = (String)wantedColumnNames.get(i);
                    Object value = rs.getObject(columnName);
                    row.put(columnName, value);
                rows.add(row);
            return rows;
          * Return all column names as a list of strings
          * @param rs query result set
          * @return list of column name strings
          * @throws SQLException if the query fails
        public static final List getColumnNames(ResultSet rs) throws SQLException
            ResultSetMetaData meta  = rs.getMetaData();
            int numColumns = meta.getColumnCount();
            List columnNames = new ArrayList(numColumns);
            for (int i = 1; i <= numColumns; ++i)
                columnNames.add(meta.getColumnName(i));
            return columnNames;
    }Anybody who lets the GC or timeouts or sheer luck handle their resource recovery for them is a hack and gets what they deserve.
    Do a search on problems with Oracle cursors being exhausted and learn what the root cause is. That should convince you.
    scsi-boy is 100% correct.
    %

  • How can I use a Lookup task to lookup from my SQL Result set and have a join

    So in my Control Flow, I have an Execute SQL Task which gets my Table result set. I then have a Foreach Loop Container that iterates through the result set and a Data Flow. The first task in the Data Flow is an OLE DB Source SQL Command that retrieves data
    columns associated with my result set. I then do a Derived Column so I can SUBSTRING from one of my data columns and now I want to perform a Lookup to my Application Database.
    How do I code my Lookup task to utilize my SQL Result set variable and match on it? I cannot use the GUI for the Lookup task as my Lookup has to have some JOINS in it.
    Thanks for your review and am hopeful for a reply.

    Can you expand on that? I'm sorry but I am new and a novice to the SSIS world and I want to do this as best I can and as efficiently as I can. Are you saying that Rajen's way suggested above is the way to go?
    A little background....external data from a 3rd party client. I'v staged that external data to a SQL Server staging table. I have to try and match that data up to our database using SSN, DOB, and Gender...and if I can't match that way then I have to try
    and match by Name. I need to make sure that there is only one and only one account for that match. If I cannot match and match one and only one, then I'll create rows on a DataAnomaly Table. If I do match, then I have to check and make sure that there is only
    one and only one Member span for that match. Similarly handle the data anomaly and then check and make sure there is a "Diabetes" claim and similarly handle the DataAnomaly accordingly.
    That's where I'm at. Sooooo are you saying to use Rajen's suggestion? I don't think I can do that because I need multiple SQL tasks and I cannot connect multiple OLE DB Source tasks.
    Any help and suggestions are greatly appreciated.
    Thanks.

  • Help with opening Adobe Reader and downloading updates

    I can not open Adobe .pdf files any longer (this started yesterday, prior to that I could open adobe files).
    When I double click a .pdf file I get this notice on my screen: Windows cannot access the specified device path or file. You may not have the appropriate permission to access file.
    So I went to the Adobe download site to download a new copy of Adobe.  When I start the download I get this on the screen:  The instruction at "0x0e3a0068" referenced memory at "0x0e3a0068."  The memory could not be written.  Then two options are listed: click OK to terminate or cancel to debug.  So I click on cancel and I get this on my screen: Internet Explorer has closed this webpage to help protect your computer.   A malfunctioning or malicious addon has caused I.E. to close this webpage.
    I don't have AVG running, I do have avast but I've disabled it.  I ran Registry Mechanic and an I.E. erasure program but nothing helps.
    I have gone into I.E. and reduced the security level to its lowest state but no joy.
    So, any ideas or suggestions on what's the problem and how to overcome it would be appreciated.  Thanks, in advance, for your reply.  Jim R.

    Hi Mike..tried that as well but no joy.  A friend of mine was looking at it all and noticed that it was an I.E. thing as far as not letting me redownload the reader so I went to Mozilla Firefox and I could download a new version but....whenever I attempt to open a .pdf file I get that message, "Windows can not open the specified device, path or file. You man not have the appropriate permissions to access the item." 
    Damn...this is irritating as I need to get to some of thos files as I need them for a Journal I'm working on as editor-in-chief. 
    It all worked just fine last Saturday but starting Monday when I was on my flight out to D.C.  no joy. 
    Sigh...Jim R.
    Jim R.
    Date: Tue, 1 Dec 2009 14:50:27 -0700
    From: [email protected]
    To: [email protected]
    Subject: Help with opening Adobe Reader and downloading updates
    Under the help menu, there is an option to repair the installation of reader. Did you try that?
    >

  • How to get the number of records of a streaming result set

    Hi guys.
    So if it wasn't a streaming result set, I would have done this:
    {noformat}myResultSet<code class="jive-code jive-java">.last();
    {color:navy}*int*{color} numResults = </code>myResultSet<code class="jive-code jive-java">.getRow();
    </code>myResultSet<code class="jive-code jive-java">.beforeFirst();
    </code>{noformat}
    but being a streaming result set, beforeFirst() throws an exception...
    So how do you get the number of records in that result set? I wanna avoid an extra count(*) query, so I would appreciate other solutions than that.

    JoachimSauer wrote:
    vanwil wrote:
    you see, for now I just use a count(*) query to get the number of records, but that's adding a lot of extra waiting time...Iterating over the result twice will surely be slower then doing the count(*).great! so what I got now is actually the fastest way there is... awesome...
    If you get an exception, then you surely have a stack trace. That should tell you what happens, or at least where.com.mysql.jdbc.MysqlIO.checkForOutstandingStreamingData(MysqlIO.java:2066)
    Why do you need to know the number of elements beforehand, anyway?I need to know the number of elements because the incoming data goes into a table. Now of course, I could use ArrayList<String[]> or something, but wouldn't that require more memory resources than Object[][] ?
    No one can tell you that, at least not without more information (say, the stack trace for example).Here's the exception message:
    java.sql.SQLException: Streaming result set com.mysql.jdbc.RowDataDynamic@10c0ef2 is still active. Only one streaming result set may be open and in use per-connection. Ensure that you have called .close() on  any active result sets before attempting more queries.

  • Barbara Brundage, can you help with PS Elements 11 and Epson R2000 printer issue?

    Seeking help with PS Elements 11 which does not work with Epson r2000 printer.  Epson tech support could not fix, said it is PS e11 problem.  Receive prompt on PS e11 screen when I try to print stating "not compatible or settings are not correct.  Have set PS to manage color and printer manages color to off.  Would appreciate any suggestions.  Thank you.

    Hi,
    Sincerely appreciate your help.  Running Windows 7 on a  Dell XPS420.  System has been very stable for years.  Before purchasing the Epson r2000, I owned an r1800 which was an excellent printer but after seven years started to exhibit paper feed problems.  The r1800 worked with all applications and I was well satisfied with the saturation, contrast, etc. printing mostly 8x10 and 11x17 prints. 
    Thank you for the information about the # of installs for PS E11, will try uninstall/reinstall this morning.
    Will let you know how things go.
    Richard
    Date: Thu, 12 Sep 2013 19:47:38 -0700
    From: [email protected]
    To: [email protected]
    Subject: Barbara Brundage, can you help with PS Elements 11 and Epson R2000 printer issue?
        Re: Barbara Brundage, can you help with PS Elements 11 and Epson R2000 printer issue?
        created by Barbara B. in Photoshop Elements - View the full discussion
    What operating system are you using?
         Please note that the Adobe Forums do not accept email attachments. If you want to embed a screen image in your message please visit the thread in the forum to embed the image at http://forums.adobe.com/message/5678022#5678022
         Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: http://forums.adobe.com/message/5678022#5678022
         To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/5678022#5678022. In the Actions box on the right, click the Stop Email Notifications link.
         Start a new discussion in Photoshop Elements by email or at Adobe Community
      For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746.

  • OBIEE: Schedule Segments with Saved Result Sets?

    Hi!
    I'd like to know how it is possible to solve this problem:
    Imagine that we have segments that were created with Segment Designer and configured with Saved Result Sets (SRS). Some of them are quicker to execute at night, so the goal is to schedule at night the execution of those sements and the respective saving of result sets. The next morning, the marketeer using Siebel Marketing, when designing and building the campaign, would only have to select the segment and then choose to use the contacts of the SRS of that segment, instead of running on-the-fly (online) the segment...
    Was may explanation clear? How is this possible?
    Thank you.
    Regards,
    Filipe Ganhão

    Update: looks like the wizard is really overwhelmed with big cubes (1.5k accounts, 20 dims @ approx 10 generations each) and just breaks.
    I haven't figured out the exact limit, but I'm able to migrate pack of about 8 dims at a time as long as I leave the accounts dim out and do that on itself.
    Cheers,
    C.

  • Need help with my iPhone 5 and my Macbook Pro.

    Need help with my iPhone 5 and my Macbook Pro.  I was purchased some music on itunes at my mac. Some reason I deleted those music from both on Mac and iPhone 5.  Today, I went to my iPhone iTunes store inside of iCloud to redownload my puchased. But those song won't able to sync back to my iTunes library on my Mac.  Can anyone help me with that ??....
    iPhone 5, iOS 6.0.1

    You've posted to the iTunes Match forum, which your question does not appear to be related to. You'll get better support responses by posting to either the iTunes for Mac or iTunes for Windows forum. Which ever is more appropriate for your situation.

  • New help with my mac air and airport extreme time capsule dont know how to save to time capsule and use as a external hd

    new help with my mac air and airport extreme time capsule dont know how to save to time capsule and use as a external hd would like 2 store my home videos and pictures on the time machine (ONLY) as the MAC AIR has storage space limited space please help. THANK YOU.

    See the info here about sharing or using the TC for data.
    Q3 http://pondini.org/TM/Time_Capsule.html
    It is extremely important you realise.. the Time Capsule was never designed for this.
    It is a backup target for Time Machine.. that is the software on the computer that does backups.. it has no direct connection to the Time Capsule.
    It has no ability to back itself up.. unlike all other NAS in the market. It is therefore likely one day you will lose all your files unless you seriously work out how to backup.
    The TC is slow to spin up the hard disk and fast to spin down. iTunes and iPhoto will continually lose connection to their respective libraries.
    iPhoto in particular is easy to corrupt when you move photos over wireless into the library.. once corrupted all is corrupt. A single photo will ruin it all.. so backup is utterly essential.
    Time Machine cannot do backups of network drives. ie the TC. You will need a different backup software like CCC. You will then need another target to backup to..

  • Why should we have to close the result set and statement

    I am told that , I have to close my connection , result set , statement objects in finally block.
    why we need to do this ?
    If close the connection wont it be sufficient?

    To ensure that resources are freed in the client and in the database server.
    Yes, closing the connection is enough. Except if you are a bit paranoid about broken JDBC drivers that don't close dependent resources properly - but I haven't seen such drivers in real life.
    One important reason why programmers close ResultSets and Statements is that they use connection pools. In that case the Connection is returned to the pool instead of closing it. It is good practice to close RS's and Statements in preparation for the day when you graduate to writing code where you too will want to use a connection pool instead of the sloooooow reconnect-close-reconnect-close-etc.

  • Need a little help with Slimbox (Lightbox clone) and Spry data sets

    Hello guys!
    First of all let me say that I'm not a programmer in any way,
    shape or form, and somehow I managed to build me a dynamic
    thumbnail gallery that reads data from an XML file and displays it
    on my webpage using a Spry data set and a slider widget (yay!)
    This is of course only thanks to the many great examples
    provided by the Adobe Spry team, and me being stubborn enough to
    keep at it, even though I don't really understand what I'm doing :D
    But I got to this point where I have basically everything
    working, except that I can't get the Slimbox (Lightbox clone)
    script to work with the Spry-generated thumbnail gallery.
    From what I could understand from other threads on this
    forum, is that I need to add an observer somewhere, only that I'm
    not sure where and how (those threads are pretty old and the
    examples aren't available anymore).
    I'm sure you guys know what I'm talking about, anyway, here's
    what I got so far:
    http://www.riotdesign.com.ar/misc/gallery/test1.html
    I have the thumbnail gallery populated from the external XML
    file, a basic page navigation using the Sliding Panels widget, and
    the Slimbox script which works only on the static test image.
    Okay I guess that's it for now, sorry for the long post and
    of course any help with this will be GREATLY appreciated :)
    Thanks & bye!

    Kev,
    Where exactly does the .evalScripts = true; text need to go?
    Does it go in the href call?
    <a href="ManageNotes.asp" title="Manage Notes" onClick="this.blur();
    Modalbox.show(this.href, {title: 'Manage Notes', width: 575}); return false;">View your notes.</a>
    Thanks for any assistance.
    J Bishop

  • Need help with Olympus E-M1 and ACR 8.3 Results

    Hi:
    1.  I'm fairly familiar with photoshop and ACR, but definitely not an expert.   I'm also very familiar with the Olympus RAW files since the E-5 (I've owned the E-5, E-M5 and several Pens);  I now recently purchased the E-M1 and I've been having problems getting decent images out of the RAW files (compared to the prior Olympus RAW files).
    2.  Problem:  it just "feels" that the overall tone curve is more abrupt, especially in the highlights.    With the prior Olympus RAW files, the transition from moving the exposure slider to the right and then getting blown out highlights was more gradual;   there just seems to be an overt decrease in "headroom" when dealing with highlights in the E-M1 RAW files.   I know this makes no sense in that the dynamic range is supposed to be greater with this camera compared to the prior ones.  
    3.  Problem:  In relation to the above issue, it also seems that the highlight slider is not as specific as it used to be in that when I move it to the left, more of the histogram seems to be affected as opposed to the bright / highlight region.   It now seems to  basically counteract any adjustments made to the exposure.   Again, this may be my imagination but it just feels this way.
    4.  Problem: In relation to the above issue, the other strange observation I've had is that although the histogram of the image shows no clipping, the image may have very bright areas with almost imperceptible detail;   when I click on it and view that data point within curves, it shows it to be well below 255.    In my lame flower shot example (it's not a good example but I couldn't find anything else right now), I would have guessed that in the brighest petal area, that it would be something like 250, but it's only 220.   But when I zoom in, there's really no texure or detail or data.  
    5.  The above issue in re: highlight rendering and control may or may not be related but it's the first time, I've been having issues and I've never had such problems with either ACR or prior Olympus cameras and thus I'm wondering if this is some issue with how ACR interprets the E-M1 file.  I did do some comparison with Capture One 7 and that does a definitely better job of highlight recovery in that it seems to more preferentially target just the highlights and definitely does a better job with color rendition.   I have Olympus Viewer 3, but it's so slow and lame, that I haven't done much testing with it.   Any thoughts and advice much much appreciated.

    Also, you might want to upload your raw file, a full-size JPG of what you posted, above, and an example from C1 to www.dropbox.com and post a public link, here, for others to experiment with.

  • Please Help! ?Result Set not updating correctly

    Hi
    This problem has been driving me mad for days now so if anyone can shed any light on it I?d be really grateful.
    I have a jTable in a frame which is populated via a database. (NB I?m using Access 2000 and the JDBC-ODBC driver v.4.00.6019). Data is added to the table via a dialog box. i.e. when the submit button on the dialog box is clicked, the new data input into textfields and text areas in the dialog box is added to the database and then the database is requeried so that the data just added is also displayed in the table. The database is updated every time with no problems, I?m sure of this, however the jTable is not. Sometimes the jTable displays the updated data, other times it doesn?t. e.g. say I input ?a? via the dialog box, this value does not appear in the table. Then I input ?b? say, and ?a? will then be added to the table or sometimes ?a? and ?b? together. Sometimes the table is updated first time no problem, other times I have the scenario mentioned above.
    I?ve looked at the result set that?s being returned when the database is requeried and it contains exactly the same data that appears in the jTable. So despite the fact that the database is definitely updated, I?m getting an incorrect result set. I?m using only the one connection object that?s created when the application is begun. I?ve even tried a dummy select statement before my proper requery of the database (as I?ve seen mentioned for a similar problem) but this doesn?t solve the problem.
    I am ?refreshing? the jTable by way of a refresh method in the jTable?s Table Model.
    The code is:
    public void refresh ()
      rows.clear();
      firstColumn.clear();
      try {
       Statement statement = conn.createStatement();
       ResultSet rs = statement.executeQuery(query);
       ResultSetMetaData rsmd = rs.getMetaData();
       boolean moreRecords = rs.next();
         do
          rows.addElement( getNextRow (rs,rsmd));
         while (rs.next() );
         statement.close();
      catch ( SQLException sqlex )
        sqlex.printStackTrace();
      this.fireTableDataChanged();
    }//End of Method  And the actual refresh method is being called when the dialog box is closed:
    void jButton4_actionPerformed(ActionEvent e) {
        TimetableDialog tdBox = new TimetableDialog (this,"Enter Date and Event",true,dealName);
        setDialogBoxLocationCentre (tdBox);
        tdBox.setVisible(true);//Code below this not executed until Dialog disposed of
        boolean validData = tdBox.returnDataValid();
          timetableModel.refresh();
         Does anyone have any idea what might be going on? It is vital that I solve this. Thanks a lot for any help.
    LGS

    According to the documentation on the Connection class. New Connections are auto-commit by default, but the commit takes place irregularly.
    "The commit occurs when the statement completes or the next execute occurs." This maybe where the ambiguity occurs. Maybe try forcing the commit connection.commit();

Maybe you are looking for

  • Using an int from one class in another class

    I am a student writing a java program on renewable energy. Simply I have a power output which is a variable called PowerOutPut. declared as (public int PowerOutPut) I have another class which is a graphics class where I display the variable PowerOutP

  • 6121 music player...music library update dont work...

    After transfering music to the phone using using nokia music manager vsn 2.0 from within PC suite, I went to music player in the phone to update music library. But i keep gettimng "no tracks" I can see and play the files in Gallery >> tracks. I have

  • Start Screen Layout missing icon

    One of the program I pinned to the Start Screen is missing. The program that's missing is the Opera browser. I created a custom start screen layout with all the programs I want in different namegroups. I put the AppsFolderLayout.bin file in the Defau

  • Update query in jdo

    I am looking for update query in KODO 4.0. How can I use named query to update "all Companies with number fo employers less then 10" ? I seen kodo.query.Query::updateAll method but not able to get an instance of it, because it seems to be reserved fo

  • Every time i double clicked the group to do some editting, it crashed and stopped working. win8 and cs6. why!!

    every time i double clicked the group to do some editting, it crashed and stopped working. win8 and cs6. why!!