Structure Search doesn't succeed at once

User dfeb81947d

26-08-2005 15:02:30

Dear Support,





I just have a feedback from some of our users that use Structure Search with a servlet under Tomcat:


Quote:
It can also occur which we have experienced since our about two-month usage that there is no match in one moment but there is match later to the same structure. So usually we have searched twice for one structure.
Quote:
In most cases the usual way is that for the first time it does not work at all then if we search again immediately after the unsuccessful search it usually works.
I'm using JChem 3.0.14 with Tomcat 4.1.29 on Oracle DB 9.2





The servlet code for structure search is:
Quote:
public void search(JChemSearch searcher, Connection conn, String table, String structure,int searchType, float similarity) throws Exception {


ConnectionHandler ch = new ConnectionHandler();


ch.setConnection(conn);


searcher.setAbsoluteStereo(JChemSearch.ABS_STEREO_ALWAYS_ON);


searcher.setDoubleBondStereoMatchingMode(StereoConstants.DBS_ALL);


searcher.setExactChargeMatching(true);


searcher.setExactQueryAtomMatching(true);


searcher.setExactStereoMatching(true);


searcher.setConnectionHandler(ch);


searcher.setStructureTable(table);


searcher.setWaitingForResult(true);


searcher.setStructureCaching(true);


searcher.setExactIsotopeMatching(false);


searcher.setExactRadicalMatching(false);


searcher.setStereoSearch(true);


searcher.setResultTableMode(JChemSearch.NO_RESULT_TABLE);


searcher.setMaxResultCount(0);


searcher.setQueryStructure(structure);


searcher.setSearchType(searchType);


if (searchType==JChemSearch.SIMILARITY) {


searcher.setDissimilarityThreshold(similarity);


}


//searcher.setInfoToStdError(true);


searcher.run();


}
The Connection comes from a ConnectionPool.


A new JChemSearch Object is initialized each time there is a new Structure Search.





Is it possible to log searcher.setInfoToStdError(true) in a file as log4j.Logger?





Myself, I was not able to reproduce the problem. Have you ever heard about it?





Thank you so far for your help.


Warmest regards





Jacques

ChemAxon 9c0afc9aaf

27-08-2005 08:01:50

Hi,
Quote:
Is it possible to log searcher.setInfoToStdError(true) in a file as log4j.Logger?
No, currently there is no option for this.


Is it a problem for you, if it's written to the standard error and stored in the server's log file ?


Quote:
Myself, I was not able to reproduce the problem. Have you ever heard about it?
No, we have never heard about such a problem.





However I think there's a possible error in your code:
Quote:
searcher.setWaitingForResult(true);
This means that no new thread is opened for the search, the execution waits until the search finishes.


This is fine in general, however in a WEB environment this can lead to a timeout between the servlet and the client (browser ?), if the search takes long.


If the first search takes longer than the second (e.g. the cache needs to be loaded /updated) this can explain the user complaints.





In our JSP example we run the search in an other thread (setWaitingForResult(false)), and in the main thread we refresh the html page every second or so, preventing timeouts:





http://www.chemaxon.com/jchem/examples/jsp1_x/index.jsp





Th source of this example is available in the package.





Best regards,





Szilard

ChemAxon 9c0afc9aaf

29-08-2005 06:41:59

PS:





This is not connected to the mentioned problem, but you do set the search type quite right.





Setting the search type changes multiple search options:





http://www.chemaxon.com/jchem/doc/api/chemaxon/jchem/db/JChemSearch.html#setSearchType(int)





These are:





* setExactChargeMatching(boolean)


* setExactIsotopeMatching(boolean)


* setExactQueryAtomMatching(boolean)


* setExactRadicalMatching(boolean)


* setExactStereoMatching(boolean)


* setStereoSearch(boolean)








Therefore if you want to fine-tune the matching options, the mentioned calls should be made after setSerachType().





Best regards,





Szilard

User dfeb81947d

29-08-2005 09:10:20

Thank you so far for your reply.





I have an other request:


When I create a ConnectionHandler from an existing Connection (from a Connection Pool: DataSource.getConnection)


Code:



private void A() {


     Connection contact = ds.getConnection();


     B(contact);


}


private void B(Connection c) {


     ConnectionHandler ch = new ConnectionHandler();


     ch.setConnection(c);


     // ...


}





// finally what have I to close?


// Connection in method A


// or ConnectionHandler in method B








I need to close the connection to give it back to the connection pool.


If I close the ConnectionHandler, it close the Connection...





Is it possible not to close the ConnectionHandler but the Connection instead?


Or do I really have to close the ConnectionHandler first?





Warm Regards,


Jacques

ChemAxon 9c0afc9aaf

29-08-2005 10:14:15

Hi,





ConnectionHandler.close() simply closes the connection and "forgets" the reference.


This is the actual code:








Code:
public void close() throws SQLException


{


    if(con != null) {


        con.close();


        con = null;


    }


}






In other words, the call is equivalent to:


Code:



ch.getConnection().close();


ch.setConnection(null);






You do not have to close the ConnectionHandler to close the connection.


It makes no practical difference if you close the connection directly, or by calling ConnectionHandler.close().





Szilard

ChemAxon 9c0afc9aaf

29-08-2005 10:43:43

On the original issue:





I recommend to store the search logs, and advise the users to note the time the query structure, and the number of hits when the problem occurs.





With this information one should be able to identify the first and second search (and possible searches between them) from the log.





These logs can give important clues if there is an error and where to look for it.





Best regards,





Szilard

User dfeb81947d

30-08-2005 07:28:58

Hi,





Thank you very much for your help.


I did as you adviced me to do.





I have an other question according to substructure search which has nothing to do with the problem.





what methods is the fastest:





convert the molfile into a Molecule object which takes time according to the structure:


Code:
private Molecule getMolecule(String molfile) {


   Molecule m = null;


   try {


      m = (new MolImporter(new MolInputStream(new ByteArrayInputStream(molfile.getBytes())))).read();


   } catch (Exception e) {


      e.printStackTrace();


   }


   return m;


}


//...


jchemsearch.setQueryStructure(getMolecule(molfile));





or directly call setQueryStructure with String?


Code:
jchemsearch.setQueryStructure(molfile);






Is it the same?


Thank you for your help.





Warmest Regards


Jacques

ChemAxon 9c0afc9aaf

30-08-2005 07:34:46

Hi Jacques,





The two solutions do exactly the same thing, none of them is faster.





Szilard

User dfeb81947d

31-08-2005 08:50:54

Thank you so far Szilard.