Page Display Records read from the database

xiaoxiao2021-03-06  112

phenomenon:

Access a database with JDBC and read a RESULTSET data record set, if the number of records is too large, the large amount of memory that occupies the client (running the Java program) (if the client is a large business The department's agent docking machine, there is a possibility that the Java program will take full memory, then report the error), and will cause the client load too heavy, the running speed is extremely slow (in the Sybase database, I have done a test. Select a test. Data records, the SQL statement is running for 4 minutes, and nearly 10 minutes is required at the Java client. solution:

Provide a user with an option to select pagination display, if the user does not want to make a page display, it is fully displayed, otherwise pagination display.

1. Define a single-page number global constant, that is, the number of data from each page. Private final static int SKIP = 100; 2. Define a global variable that determines a certain paging bar, that is, the current display of the currently displayed data. Private static int Cur = 0;

3. Define a RESULTSET global variable so that use private static java.sql.result rs = null; 4. Open a database connection class.Forname (Sqldriver); java.sql.connection conn = drivermanager.getConnection (URL, String) username, (string) passwd) Statement Stmt = conn.createstatement (); string searchsql = "..."; rs = stmt.executeQuery (searchsql); 5. Get query result set data (generally Inquiry button response event function) ... NextButton.seTenable (TRUE); cur = 0; While (Cur 0) {.. .. Clear the content displayed on the previous page (Cur

转载请注明原文地址:https://www.9cbs.com/read-125282.html

New Post(0)