Error while exporting data in "Jchem .Net API"

User 73ad691ca3

21-08-2012 09:59:25

 

Hi,


We are going to implement "the exporting of structure with data from structure table and other data tables" using the Jchem .Net API(i.e,. custom export, based on the select query).


So we are using "Exporter class of jchem" to export the sdf data from structure table based on the select query.


When we try to export the sdf data using "Exporter class of jchem", jchem throws exception. Jchem throws the exception when we set "the select query" to the exporter object. 


Exception:


Transfer exception:


Unexpected error during DB export init: null


----


Jchem version details:


-->JChem .NET API 5.10.3.437


-->Oracle database


Note: But when we try to export the sdf data for "the entire structure table"(i,e. setTableName method), we are able to get the exported results from the jchem exporter class.


Below is the code we used for exporting structure data(i,e,. setSelectQuery), for this jchem throws exception:


/////////////////////////////////////////////////////// using setSeletQuery /////////////////////////////////////////////////


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using java.io;
using System.Configuration;
using chemaxon.util;
using java.sql;
using chemaxon.jchem.db;


namespace JChemBaseSearch
{
    public class Exporter1
    {
        public Exporter1()
        {


        }


        private static ConnectionHandler getConnectionHandler()
        {
            string url = ConfigurationManager.AppSettings["url"];//jdbc:oracle:thin:@dbora:1521:jchem
            string username = ConfigurationManager.AppSettings["username"];//jcm
            string password = ConfigurationManager.AppSettings["password"];//jcm


            try
            {
                DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
                Connection conn = DriverManager.getConnection(url, username, password);


                ConnectionHandler ch = new ConnectionHandler();
                ch.setConnection(conn);


                return ch;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }


        public void ExportQueryData()
        {
            try
            {
                //Note: create the folder, "c:/test"
                string fileName = "c:/test/sdfTest12345.sdf";
                string tname = "test";


                string QUERY = "SELECT  T.CD_STRUCTURE, T.CD_ID, B.BATCH_NUMBER FROM TEST T INNER JOIN BATCH_DETAILS B ON T.CD_ID = B.CD_ID"; //"SELECT  TEST.CD_STRUCTURE FROM TEST WHERE TEST.CD_ID = 478";


                int format = Transfer.__Fields.SDFILE;
                File file = new File(fileName);
                OutputStream os = new FileOutputStream(file);
                Exporter ex = new Exporter();
                ex.setConnectionHandler(getConnectionHandler());


                //Note: comment below 2 lines, if you want to export the data of query results
                //ex.setTableName(tname);
                //ex.setDefaults(false);


                ex.setOutputStream(os);
                ex.setFormat(format);


                //Note: uncomment below line, if you want to export the data from the structure table(here it is "test")
                ex.setSelectStatement(QUERY); //when we uncomment this line, we get error. To do:


                int written = ex.writeAll();
            }
            catch (Exception ex)
            {
                throw ex;
            }


        }


    }
}


////////////////////////////////////////////////////////////////////////////


//////////////Code to export structure data from a table/////////////this is working fine//////////////////////


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using java.io;
using System.Configuration;
using chemaxon.util;
using java.sql;
using chemaxon.jchem.db;


namespace JChemBaseSearch
{
    public class Exporter1
    {
        public Exporter1()
        {


        }


        private static ConnectionHandler getConnectionHandler()
        {
            string url = ConfigurationManager.AppSettings["url"];//jdbc:oracle:thin:@dbora:1521:jchem
            string username = ConfigurationManager.AppSettings["username"];//jcm
            string password = ConfigurationManager.AppSettings["password"];//jcm


            try
            {
                DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
                Connection conn = DriverManager.getConnection(url, username, password);


                ConnectionHandler ch = new ConnectionHandler();
                ch.setConnection(conn);


                return ch;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }


        public void ExportQueryData()
        {
            try
            {
                //Note: create the folder, "c:/test"
                string fileName = "c:/test/sdfTest12345.sdf";
                string tname = "test";


                string QUERY = "SELECT  T.CD_STRUCTURE, T.CD_ID, B.BATCH_NUMBER FROM TEST T INNER JOIN BATCH_DETAILS B ON T.CD_ID = B.CD_ID"; //"SELECT  TEST.CD_STRUCTURE FROM TEST WHERE TEST.CD_ID = 478";


                int format = Transfer.__Fields.SDFILE;
                File file = new File(fileName);
                OutputStream os = new FileOutputStream(file);
                Exporter ex = new Exporter();
                ex.setConnectionHandler(getConnectionHandler());


                //Note: comment below 2 lines, if you want to export the data of query results
                ex.setTableName(tname);
                ex.setDefaults(false);


                ex.setOutputStream(os);
                ex.setFormat(format);


                //Note: uncomment below line, if you want to export the data from the structure table(here it is "test")
                //ex.setSelectStatement(QUERY); //when we uncomment this line, we get error. To do:


                int written = ex.writeAll();
            }
            catch (Exception ex)
            {
                throw ex;
            }


        }


    }
}


/////////////////////////////////////////////////////////


Please resolve this issue asap.


we are waiting for your reply, and help us how to solve this issue.


We want the export functionality to be working fine.


Please let us know, if you need any other information regarding this.


Thanks and Regards,


D.Senthil kumar vijai.


ChemAxon eb65a25631

21-08-2012 13:49:52

see: https://www.chemaxon.com/forum/viewpost43856.html#43856