User 7fc1506f44
11-12-2012 18:30:51
I'm having a problem query by substructure, when I do the query returns the error below error:
my code below :
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
import org.mentawai.core.ApplicationManager;
import org.mentawai.db.*;
import chemaxon.formats.MolFormatException;
import chemaxon.jchem.db.DatabaseSearchException;
import chemaxon.jchem.db.*;
import chemaxon.jchem.db.PropertyNotSetException;
import chemaxon.sss.SearchConstants;
import chemaxon.sss.search.JChemSearchOptions;
import chemaxon.util.ConnectionHandler;
import java.io.IOException;
import java.sql.*;
import java.sql.DriverManager;
import java.sql.SQLException;
import org.mentawai.db.DBCPConnectionHandler;
import sun.jdbc.odbc.ee.ConnectionPool;
/**
*
* @author KAYAMEN
*/
public class SistematXSubConsulta {
private Connection connection;
public void consultaSubEstrutura() throws ClassNotFoundException, SQLException {
}
public static void main(String[] args) throws ClassNotFoundException, SQLException, MolFormatException, IOException, DatabaseSearchException, PropertyNotSetException, InstantiationException, IllegalAccessException {
SistematXSubConsulta cc = new SistematXSubConsulta();
cc.consultaSubEstrutura();
String driverName = "org.gjt.mm.mysql.Driver"; //MySQL MM JDBC drive
Class.forName(driverName);
String serverName = "127.0.0.1";
String mydatabase = "sistemat";
String url = "jdbc:mysql://" + serverName + "/" + mydatabase; // a JDBC url
String username = "root";
String password = "";
Connection connection = DriverManager.getConnection(url, username, password);
String propertyTableName = "BCOMP";
ConnectionHandler ch;
//In case of a new login
ch = new ConnectionHandler();
ch.setDriver(driverName);
ch.setUrl(url);
ch.setLoginName(username);
ch.setPassword(password);
ch.setPropertyTable(propertyTableName);
String mol = "
- c1cccc([Cl,Br])c1"; // Query structure
String structureTableName = "FINGERPRINT";
JChemSearch searcher = new JChemSearch(); // Create searcher object
searcher.setQueryStructure(mol);
searcher.setConnectionHandler(ch);
searcher.setStructureTable(structureTableName);
JChemSearchOptions searchOptions = new JChemSearchOptions(SearchConstants.DUPLICATE);
searcher.setSearchOptions(searchOptions);
searcher.run();
}
}
Exception:
Exception in thread "main" java.lang.NullPointerException
at chemaxon.jchem.db.DatabaseOptions.getDBMSType(DatabaseOptions.java:583)
at chemaxon.jchem.db.DatabaseProperties.<init>(DatabaseProperties.java:150)
at chemaxon.jchem.db.JChemSearch.initConnection(JChemSearch.java:3148)
at chemaxon.jchem.db.JChemSearch.init(JChemSearch.java:3949)
at chemaxon.jchem.db.JChemSearch.search1(JChemSearch.java:2377)
at chemaxon.jchem.db.JChemSearch.search(JChemSearch.java:2274)
at chemaxon.jchem.db.JChemSearch.setRunning(JChemSearch.java:1994)
at chemaxon.jchem.db.JChemSearch.run(JChemSearch.java:2017)
at sistematxsubconsulta.SistematXSubConsulta.main(SistematXSubConsulta.java:82)
Java Result: 1