help pls with jdbc-mysql problem

From: matt (ty_li_at_yahoo.com)
Date: 11/12/04


Date: 11 Nov 2004 15:31:11 -0800

Thanks in advance for any advice!!!

Mysql jdbc driver problem

I query a mysql db with JDBC connector. The program check DB every 10
second. At each query, it checks whether new rows are written into DB
table. If yes, fetch the new
Rows and print on stdout.
The problem is:
1. there is a 2-5 minutes time lag between the time the row is written
and the time the row is printed in Java program.
2. some rows get duplicated. It means, one query will sometimes show
some rows which are already displayed in previous query.
3. some rows get dropped.

The driver I used is:
MySQL Connector/J 3.0.7 Stable (formerly MM.MySQL)
MySQL AB's JDBC Driver for MySQL
Copyright (c) 2002 MySQL AB
Algorithm of code

  //establish connection
  //make sql string
While(true)
{

              rs = stmt.query(sqlstring)
             //directly go to the next row from the last row read in
last query
                   rs.absolute(prevLastRow+1);
                        
                     //loop to retrieve data in the ResultSet rs
                        while (rs.next()) {
                                      …..
                                    }
                                //make cursor point to last row
                  rs.last();
                //store a value in last row
                    lastCid=rs.getString(2);//update last cid
                //update the value of prevLastRow
                    prevLastRow=rs.getRow();
                 rs.close();
          
                    //sleep for 120 second
       
          Thread.sleep(readDBFrequency);
} //outer loop



Relevant Pages

  • Re: Problem with SQL and Recordset
    ... This assumes that the name of the subform control on the parent form is the ... NextSuffix field from the "query" to be entered into the Suffix field on ... Dim mySQL As String ...
    (microsoft.public.access.modulesdaovba)
  • Re: [Q]Problems related to the MySQL linked Server.
    ... The error messge when I query data with following SQL. ... select @v_intUserNo = uno ... where userid = 'testid' ... I have two questions about the linked server for the MySQL. ...
    (microsoft.public.sqlserver.odbc)
  • Re: Performance MySQL
    ... schicke erst den Query an die Datenbank ab, ... Möglichkeit von Concurrent Inserts nur MyISAM Storages ein. ... > MySQL bis jetzt noch nichts zu bieten. ... Welcher Tabellentyp? ...
    (de.comp.datenbanken.mysql)
  • Re: where to get mySQL questions answered?
    ... After resolving some performance issues with mysql in building initial ... soon as I add an OR to my WHERE x LIKE '%blah%' type queries. ... My php code dynamically builds an sql query. ...
    (comp.lang.php)
  • Re: MySQL Performance
    ... Try enabling slow query logging, as well as maybe try to isolate if the ... load is coming from any particular query... ... > MySQL server seems to run fine as long as I watch it, ... > to 97% CPU usage. ...
    (freebsd-isp)