User 73ad691ca3
20-08-2012 13:29:19
Hi, We are getting error while exporting structures from "Jchem Exporter" using "JChem .NET API 5.10.3.437". Actually we have implemented Exporting structures with data from structure table and other data table, this is working fine in java. Our requirement is to query structure and other table data, and export the data 'to string' or 'write to a file', This has to be done using Jchem for .NET API. But we want the exporting functionality in dotnet using "Jchem for .Net API". We had written the below code for dotnet. And while we run the code in dotnet we are getting the below error. Error: Unexpected error during DB export init: null Below is the code we are using: ////////////////////////////////////////////////////////////////////////// using System; namespace JChemBaseSearch /// <summary> try ConnectionHandler ch = new ConnectionHandler(); return ch; OutputStream outs = null; try /* java.io.File file = new java.io.File("c:/test/sdfTest.sdf"); exp.setOutputStream(outs); } } } ///////////////////////////////////////////////////////////////////////////// Please let us know why the jchem throws error. Please resolve this issue asap. Please let us know if you need any other information regarding this. Thanks & Regards, Senthil kumar vijai.
using System.Text;
using System.Data;
using System.Configuration;
using java.sql;
using chemaxon.util;
using chemaxon.struc;
using chemaxon.jchem.db;
using chemaxon.sss.search;
using java.io;
{
/// DataAccess class using JDBC driver
/// </summary>
public static class DataAccess
{
private static ConnectionHandler getConnectionHandler()
{
string url = "jdbc:oracle:thin:@dboracle01:1521:jchem"; //read configuration settings from App.config
string username = "jcm";
string password = "jcm";
{
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
Connection conn = DriverManager.getConnection(url, username, password);
ch.setConnection(conn);
}
catch (Exception ex)
{
throw ex;
}
}
public static void ExportData()
{
string sdfResult = string.Empty;
string qry = "select t.CD_STRUCTURE, t.CD_ID from test t";// where t.CD_ID = 512";
string outputcolnames = "CD_ID:CD_ID";
{
Exporter exp = new Exporter();
exp.setConnectionHandler(getConnectionHandler());
exp.setSelectStatement(qry);
exp.setOutputFieldConversion(outputcolnames);
OutputStream outs = new OutputStream()
{
private StringBuilder string = new StringBuilder();
//@Override
public void write(int b) throws IOException
{
this.string.append((char) b );
}
//Netbeans IDE automatically overrides this toString()
public String toString(){
return this.string.toString();
}
};
*/
file.getParentFile().mkdirs();
outs = new java.io.FileOutputStream(file);
exp.setFormat(1);
exp.writeAll();
catch (Exception ex)
{
throw ex;
}
finally
{
outs.flush();
outs.close();
}
}