views:

30

answers:

2

Hi,

I wanna use this vector as DataSource for my Jtable.There is 4 Column here (ADI,SOYADI,BABA ADI, ANA ADI). ResultSet is adding every row to vector named _kisivector.This is my DataSource.But i dont wanna get whole records at start.I wanna get only 5 records from this vector.Than there will be 2 button , back and forward.When i click Forward it will go for other 5 record.And when i click back button , it will go for 5 previous record.

Is there any example for this ?

Thanx.

private Vector getSonuc(String _ad){


            Vector _kisivektor = new Vector();
            PreparedStatement stmt = null;

            ResultSet rs = null;

            try {

                Class.forName("oracle.jdbc.driver.OracleDriver");


                Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@xx.xx.xx.xx.:1521:xxxx", "xxx", "xxx");

                stmt = conn.prepareStatement("select * from t_gnl_kisi where ADI like ?");

                stmt.setString(1, _ad+"%");

                rs = stmt.executeQuery();

                while (rs.next()) {
                _kisivektor.add(rs.getString("ADI"));
                _kisivektor.add(rs.getString("SOYADI"));
                _kisivektor.add(rs.getString("ANA_ADI"));
                _kisivektor.add(rs.getString("BABA_ADI"));
                        }
                stmt.close();
                            rs.close();

            }
            catch (Exception e) {

                e.printStackTrace();

            }

return _kisivektor;

            }



        }
A: 

There is a pattern name for this: Value List Handler which is a specific form of Lazy Loading.

richj
+1  A: 

You can use the solution discussed here, http://forums.sun.com/thread.jspa?threadID=5425845&tstart=1 (This is on demand fetching)

This is prefetching

http://forums.sun.com/thread.jspa?threadID=5371696

Finally if you want to get batch of data of 5 rows. You can subclass the Data Model and only read 5 rows and keep connection open. When "Back" or "Forward" buttons are pressed you can scroll the resultset to that many records (you anyway are going to have a twoway scrollable result set)

Calm Storm