About initialization setting in calling structure search API

User 22c88daf92

07-12-2012 02:11:06

hello!


Usually, we do search as following:


 public static int[] subStrucSearch(String queryStruc)
    {          
     JChemSearch jcs = new JChemSearch();     
     JChemSearchOptions jcSearchOptions = new JChemSearchOptions(SearchConstants.SUBSTRUCTURE);


        int hitSum=0;
        int[] hitID=null;
       
        try {                   
       jcs.setStructureTable(structTableName);
       jcs.setQueryStructure(queryStruc);
       jcs.setSearchOptions(jcSearchOptions);
       jcs.setConnectionHandler(getConnJCB());
       jcs.run();
                   
       hitSum=jcs.getResultCount();             
       .........................................................     


Every time we call this search method in our software, we must initialize these setting again(as red color code). So, we want to know whether there has a more efficiency method to initialize  these setting once?


Is there any java examples? Thanks!

ChemAxon d9cc14700b

07-12-2012 10:25:18

Hi,


I don't think so. Every time you would like to execute a search, then you have to create a new JChemSearch instance with the necessary parameters and options. Could you please provide me an example how would like to use this?


 


Thanks and Regards,
Gabor 

ChemAxon 9c0afc9aaf

07-12-2012 16:28:07

Hi,


 


You should be able to re-use the same JChemSearch object in subsequent searches by simply setting only what has changed (e.g. query structure) and running the search again with run().


If you notice any problems with this (there should not be any) please report it as a bug.


Note: you should not use the same JChemSearch object at the same time from multiple threads, in that case you need multiple instances.


Szilard