Question about using JChemSearch and retrieving other fields

User 2f67f74af0

18-03-2009 18:08:01

Hello every one,





I have a simple jsp page in which I'm trying to return a field from a table.





The getResults() method returns the cd_id values.





I want to return another field which is cd_DRUGBANK_ID





The Table stucture is:











Code:
+---------------------+--------------+------+-----+---------+----------------+


| Field               | Type         | Null | Key | Default | Extra          |


+---------------------+--------------+------+-----+---------+----------------+


| cd_DRUGBANK_ID      | varchar(20)  | YES  |     | NULL    |                |


| cd_id               | int(11)      | NO   | PRI | NULL    | auto_increment |


| cd_structure        | mediumblob   | NO   |     | NULL    |                |


| cd_smiles           | text         | YES  |     | NULL    |                |


| cd_formula          | varchar(100) | YES  |     | NULL    |                |


| cd_sortable_formula | varchar(255) | YES  | MUL | NULL    |                |


| cd_molweight        | double       | YES  |     | NULL    |                |


| cd_hash             | int(11)      | NO   | MUL | NULL    |                |


| cd_flags            | varchar(20)  | YES  |     | NULL    |                |


| cd_timestamp        | datetime     | NO   |     | NULL    |                |


| cd_fp1              | int(11)      | NO   |     | NULL    |                |


| cd_fp2              | int(11)      | NO   |     | NULL    |                |


| cd_fp3              | int(11)      | NO   |     | NULL    |                |


| cd_fp4              | int(11)      | NO   |     | NULL    |                |


| cd_fp5              | int(11)      | NO   |     | NULL    |                |


| cd_fp6              | int(11)      | NO   |     | NULL    |                |


| cd_fp7              | int(11)      | NO   |     | NULL    |                |


| cd_fp8              | int(11)      | NO   |     | NULL    |                |


| cd_fp9              | int(11)      | NO   |     | NULL    |                |


| cd_fp10             | int(11)      | NO   |     | NULL    |                |


| cd_fp11             | int(11)      | NO   |     | NULL    |                |


| cd_fp12             | int(11)      | NO   |     | NULL    |                |


| cd_fp13             | int(11)      | NO   |     | NULL    |                |


| cd_fp14             | int(11)      | NO   |     | NULL    |                |


| cd_fp15             | int(11)      | NO   |     | NULL    |                |


| cd_fp16             | int(11)      | NO   |     | NULL    |                |















The returnID.jsp code is:








Code:
<%@page import="chemaxon.descriptors.*, chemaxon.jchem.db.*, chemaxon.util.*,java.sql.*"%>








<%


//String molfile = (String)request.getParameter("molfile");


String smi = "CN1C=NC2=C1C(=O)N(C)C(=O)N2C";


if(smi != null)


{


try{


ConnectionHandler ch = new ConnectionHandler();


ch.setDriver("com.mysql.jdbc.Driver");


ch.setUrl("jdbc:mysql://localhost/test");


ch.setLoginName("uname");


ch.setPassword("pw");


ch.connect();


String structureTableName = "tableName";


JChemSearch searcher = new JChemSearch(); // Create searcher object


searcher.setQueryStructure(smi);


searcher.setConnectionHandler(ch);


searcher.setStructureTable(structureTableName);


searcher.setWaitingForResult(true);


searcher.setSearchType(JChemSearch.SIMILARITY);





searcher.run();


int cd[]=searcher.getResults();


for(int i=0 ;i< cd.length ;i++)


out.println(cd[i]);


}


catch(SQLException e){


out.println("message: "+e);


}





}





else{ out.println("You have an Empty Query");


}


%>











[/i]









Any help please.





Please note I'm using ChemAxon V 5.2 java V 1.6, tomcat V 6.0





on Redhat Linux Enterprise








Thank you.














--Saif

ChemAxon 42004978e8

18-03-2009 18:22:03

Hi Saif,





You can run a separate SQL query for retrieving the desired columns based on the already known cd_id values.





The documentation contains java and JSP examples:





http://www.chemaxon.com/jchem/doc/guide/search/index.html#sss_retrieve_through_SQL





You can embed the java code modified with your DB field values.





Bye,





Robert

User 2f67f74af0

18-03-2009 20:35:37

Thank you Robert for your prompt answer.





I get it working now.














--Saif