Following is the code which is returning data from correct table but with 3
rows pripor entry.
Emaple it incremental PK is 10 then it will return mr record for 7 , if
query is changed with other column, same problem noticed.


                File INDEX_DIR = new File("index");
                Directory dir = FSDirectory.open(INDEX_DIR);
                IndexSearcher searcher = new 
IndexSearcher(IndexReader.open(dir));
                Query query = new
QueryParser(Version.LUCENE_40,"lawname",analyzer).parse("Law");   
                
                TopDocs hits = searcher.search(query,10);
                
                Class.forName("org.sqlite.JDBC");  
                Connection conn =
DriverManager.getConnection("jdbc:sqlite:\\D:\\Sqlite\\SysDb.db");
                
                //Quering Laws table
                String sql = "select * from laws where lawid = ?;";   
                PreparedStatement pstmt = conn.prepareStatement(sql);
                   
                for (int i = 0; i < hits.totalHits; i++){
                   int id = hits.scoreDocs[i].doc;
                   pstmt.setInt(1, id);   
                   displayResults(pstmt, "laws");   
                }





        void displayResults(PreparedStatement pstmt,String tableName) {   
           try {   
              ResultSet rs = pstmt.executeQuery();   
              
              System.out.println("********" + tableName + "********");
              
              while (rs.next()) {   
                 System.out.println(rs.getString("lawid"));   
                 System.out.println(rs.getString("lawname")+"\n");   
              }   
           } catch (SQLException e) {   
              e.printStackTrace();   
           }   
        }



--
View this message in context: 
http://lucene.472066.n3.nabble.com/Wrong-record-returned-retrieved-tp4048588.html
Sent from the Lucene - Java Developer mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to