简体   繁体   English

如何使用Vector作为数据源?

[英]How to use Vector as DataSource?

I want to use this vector as DataSource for my Jtable. 我想将此向量用作Jtable的数据源。 There are four columns here (ADI, SOYADI, BABA ADI, ANA ADI). 这里有四列(ADI,SOYADI,BABA ADI,ANA ADI)。 ResultSet is adding every row to vector named _kisivector. ResultSet将每一行添加到名为_kisivector的向量中。 This is my DataSource. 这是我的数据源。

But I don't want to get whole records at start. 但是我不想一开始就获得完整的记录。 I want to get only 5 records from this vector. 我只想从此向量中获得5条记录。 Then there will be 2 button, back and forward. 然后将有2个按钮,向前和向后。 When I click Forward it will go for other 5 record. 当我单击“前进”时,它将进入其他5条记录。 And when I click back button, it will go for 5 previous record. 当我单击“后退”按钮时,它将保留5条先前的记录。

Is there any example for this? 有什么例子吗?

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;

            }



        }

You can use the solution discussed here, http://forums.sun.com/thread.jspa?threadID=5425845&tstart=1 (This is on demand fetching) 您可以使用此处讨论的解决方案, http://forums.sun.com/thread.jspa?threadID = 5425845&tstart = 1 (这是按需提取)

This is prefetching 这是预取

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

Finally if you want to get batch of data of 5 rows. 最后,如果要获取5行数据批次。 You can subclass the Data Model and only read 5 rows and keep connection open. 您可以将数据模型作为子类,仅读取5行并保持连接打开。 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) 当按下“后退”或“前进”按钮时,您可以将结果集滚动到那么多条记录(无论如何,您将具有双向滚动结果集)

为此有一个模式名称: 值列表处理程序 ,是延迟加载的一种特定形式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM