Conneting the microsoft excel sheet using jdbc

HI all
my requirement is to connect to the excel sheet using the jdbc odbc dsn and read the worksheets and get the data.
i have created the dsn using vb scripting
so when i click on a button. a dsn is created dynamically and the same dsn is passed as parameter to the system which will call a java program
the java program will us the dsn to connect to the excel sheet to read the data.
This is working fine
the problem is sometimes the following exception is raised.
java.sql.SQLException: [Microsoft][ODBC Excel Driver] Cannot open database '(unknown)'. It may not be a database that your application recognizes, or the file may be corrupt.
at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcConnection.initialize(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at com.zt.ebiz.install.client.ExcelDriver.getConnection(ExcelDriver.java:290)
at com.zt.ebiz.install.client.ExcelDriver.getHostInfo(ExcelDriver.java:337)
at com.zt.ebiz.install.client.InstallClient.executeActions(InstallClient.java:188)
at com.zt.ebiz.install.client.InstallClient.main(InstallClient.java:123)
For this we are just restarting the system.
Again it works fine.
i would like to know the cause of this problem.
please help me in this
thanks
Vijay Sunder

It may be occured because of connection closing, make it sure to close connections after your transactions completed.

Similar Messages

  • Retrieval of Information from Excel Sheet using JDBC-ODBC

    Hello,
    Currently I am writing a program that extracts information fromexcel sheet. This excel sheet have some values in Chinese. I am able to extract English character from the different column in excel, but if some column contain chineese valur then it prints ???. After that I looked on net and found some details in to convert Big5 (Chinese) character into unicode, but this is not working and in that case nothing is displayed. I am attaching the my code. In my code the 'customer' field contain chinese character.
    import java.io.ByteArrayInputStream;
    import java.io.InputStreamReader;
    import java.io.BufferedReader;
    import java.io.Reader;
    import java.io.IOException;
    import java.sql.*;
    public class ExcelJDBC
         Connection con;
         Statement stmt;
         public ExcelJDBC(String url)
              try
                   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
              catch(java.lang.ClassNotFoundException e)
                   System.err.print("ClassNotFoundException: ");
                   System.err.println(e.getMessage());
              try
                   con = DriverManager.getConnection(url, "", "");
                   stmt = con.createStatement();
              catch(SQLException ex)
                   System.out.println("SQL EXCEPTION OCCURED");
                   System.err.println("SQLException: " + ex.getMessage());
                   ex.printStackTrace();
         public void sql(String sql)
              try
                   stmt.execute(sql);
              catch(SQLException ex)
                   System.out.println("SQL EXCEPTION OCCURED");
                   System.err.println("SQLException: " + ex.getMessage());
                   ex.printStackTrace();
         public void closeAll()
              try
                   stmt.close();
                   con.close();
              catch(SQLException ex)
                   System.out.println("SQL EXCEPTION OCCURED");
                   System.err.println("SQLException: " + ex.getMessage());
                   ex.printStackTrace();
         //big5 to unicode conversion
         private String b2u(String str2convert) throws IOException
              System.out.println("The input string is :" + str2convert);
              StringBuffer buffer = new StringBuffer();
              byte[] targetBytes = str2convert.getBytes();
              ByteArrayInputStream stream = new ByteArrayInputStream(targetBytes);
              InputStreamReader isr = new InputStreamReader(stream,"Big5");
              Reader in = new BufferedReader(isr);
              int chInt;
              while((chInt = in.read()) < -1)
                   buffer.append((char)chInt);
              in.close();
              System.out.println("The output string is :" + buffer.toString());
              return buffer.toString();
         public void sqlQuery(String sql)
              try
                   ResultSet rc = stmt.executeQuery(sql);
                   if(rc != null)
                        int count = 0;
                        while (rc.next())
                             String value = "";
                             value = b2u(rc.getString("workorder"));
                             System.out.println("The workorder is : "+value);
                             String customer = rc.getString("Customer");
                             value = b2u(customer);
                             System.out.println("The Customer is : "+value);
                             count++;
                        System.out.println("Entering in loop " count " time.\n");
              catch(SQLException ex)
                   System.out.println("SQL EXCEPTION OCCURED");
                   System.err.println("SQLException: " + ex.getMessage());
                   ex.printStackTrace();
              catch(IOException ex)
                   System.out.println("IO EXCEPTION OCCURED");
                   System.err.println("IOException: " + ex.getMessage());
                   ex.printStackTrace();
    public static void main(String[] args)
         String url = "jdbc:odbc:detailsdsn";     
         try
              ExcelJDBC ej = new ExcelJDBC(url);
              ej.sqlQuery("SELECT \"workorder\", \"Customer\" FROM \"Sheet1$\"");
              ej.closeAll();
         catch(Exception ex)
              System.out.println("SQL EXCEPTION OCCURED");
              System.err.println("SQLException: " + ex.getMessage());
              ex.printStackTrace();
    I will highly appriciate any answer of my problem.
    Regards,
    Ruchi

    Try to find out, what characters really are in your string customer.
    I assume you used System.out.print..(), when you got them as '?'.
    Find out which unicodes they are!
    Afterwards I see two possibilites:
    Either
    1) you see real unicodes for Chinese characters, and it was only the unability of System.out to print them others than as '?', then you can convert these characters however you want. Maybe your further processing can handle them directly as unicode.
    or
    2) you get really '?' in your string. Then Excel (or JDBC or ODBC or ???) hasn't been able to transmit these Chinese characters to your program others than converting them all into '?'. Then you are lost, because you can't know which Chinese character each '?' originally could have been.
    Hope this helps.
    Please tell us, which you experienced, 1) or 2).

  • How to append in excel sheet using Java

    Can anybody help me out in figuring out as how to append in already existing excel sheet using Java.
    I am able to to write in the existing excel sheet using HSSF but is not able to append the data row wise.
    So plz tell me how to do the same.

    Manisha_7 wrote:
    Thnx for the link......No problem.
    but i alsot wanted to know if apart from using poi there is a way to append the data in excel sheet like using JExcel.Don't know. JExcel is also not apart of Java's core API.

  • The goal is to synchronize an excel sheet using Microsoft Excel 2010 with Sharepoint 3.0

    The goal is to synchronize an excel sheet using Microsoft Excel 2010 with Sharepoint 3.0. We have already installed an add-in (Excel 2007 Add-in: Synchronizing Tables with SharePoint Lists) that was supposed
    to help the synchronization of excel to Sharepoint, but it did not work. We would like to synchronize information about a calendar from excel to Sharepoint 3.0, so every time a change is made in excel it automatically updates in Sharepoint.

    ootb, changes in excel don't sync with a SharePoint list, the other way around is possible.
    Kind regards,
    Margriet Bruggeman
    Lois & Clark IT Services
    web site: http://www.loisandclark.eu
    blog: http://www.sharepointdragons.com

  • How to get the password of a password protected Excel Sheet using java/jxl

    Hi ,
    how to get the password of a password protected Excel Sheet using java / jxl program.
    plz any one help me .
    Ramesh P
    [email protected]

    If they've implemented the password system correctly there probably isn't a way of getting the password at all.

  • How do I get the last COLUMN in an Excel Sheet using Report Generation toolkit in LV7.1?

    I am trying to get the last column in an Excel sheet using the Report Generation toolkit. The function "Excel Get Last Row" does not give last column info. Is there a function that will do this?
    Thanks

    Hello –
    I think the following example program might be helpful to get you started programming your application.
    Get Excel Data from Specified Field.
    Hope this helps!
    SVences
    Applications Engineer
    National Instruments

  • Upload Excel sheet using Data Integrator 6.1?

    hi all ,
    Upload Excel sheet using Data Integrator? and how to create ODBC for the PC and jobserver i am using version 6.1? i am using excel as my one of the data source and tell me how to use different types of data sources in DI . after uploading the xl file if i apply any transform on the excel data i will give error like
    Posted: 25 Sep 2008 04:30
    Post subject: Re: Upload Excel sheet using Data Integrator? 
    I am getting the error like
    3128 292 CON-120302 09-25-08 09:59:40 ODBC call <SQLDriverConnect> for data source <sas> failed: <[Microsoft][ODBC Driver Manager] Data source name not found and no
    3128 292 CON-120302 09-25-08 09:59:40 default driver specified>. Notify Customer Support.
    1512 2992 CON-120302 09-25-08 09:59:41 ODBC call <SQLDriverConnect> for data source <sas> failed: <[Microsoft][ODBC Driver Manager] Data source name not found and no
    1512 2992 CON-120302 09-25-08 09:59:41 default driver specified>. Notify Customer Support.
    Please help me out
    Thank u

    Hi Shonti,
    The DI 11.7 installer can be used to upgrade a DI 6.1 local repository (e.g. the upgrade is supported).  This will migrate all jobs and flows.  They will remain intact, however, this is always a major migration effort and should not be taken lightly.  If you do upgrade, please make sure this is a planned effort with rigorous testing and validation.  You should also ensure that you consult the release notes and [supported platforms documentation|https://websmp110.sap-ag.de/~form/sapnet?_SHORTKEY=01100035870000712240&_SCENARIO=01100035870000000202] for the 11.7 package you intend to install.  The DI 11.7 documentation also contains info about how to install and configure the Excel Adapter, and what functionality it provides.
    Thanks,
    ~Scott

  • Can't read special characters in an excel file using JDBC

    Hi! I 've a code to read an excel file using JDBC-ODBC bridge. I can read the values, but any special characters is readed wrong, just symbols. The special characters are of spanish language. This is my code:
                    Locale currentLocale;
              currentLocale = new Locale("es", "MX");
              Locale.setDefault(currentLocale);
                   Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
                   c = DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Excel Driver (*.xls)};DBQ=comisionesperfiles.xls");
                   stmnt = c.createStatement();
                   String query = "Select * from [Hoja1$]" ;
                   ResultSet rs = stmnt.executeQuery( query );
                   while( rs.next() ){
                        String valor = rs.getString(2) ;
                        if(valor != null && !"null".equalsIgnoreCase(valor)){
                             if(!comisiones.contains(valor)){
                                  System.out.println(valor);
                                  comisiones.add( valor );
                   rs.close();
                   stmnt.close();As you can see, I've tried to set the locale, but it didn't work.
    I'm using Excel 2003, Java Version 1.4.2_07 and Windows XP Professional (in latin american spanish).
    Hope someone can help me!

    FYI: Apache's POI can read/write Excel files in Java:
    http://jakarta.apache.org/poi/index.html

  • Generating Excell Sheet using Reports 9i

    Hello,
    I wanna know how can I do to generate one excell sheet using reports, without
    use the option that4s generate text file using tab. I wanna know if someone have
    example codes, or library4s.
    Thanks,
    Paulo Sergio

    Here are some notes we created from the demo below. This works great for generating true formated excel output in 9i Reports using 9ias Rel2.
    Notes from
    http://otn.oracle.com/products/reports/htdocs/getstart/demonstrations/index.html
    Output to Excel with Oracle9i Report
    1.     Create an Excel template for the report. It should contain generic information such as title, logo and column headers
    2.     Cretae a sample line of data in the spreadsheet
    3.     Save the Excel spreadsheet as a Web page. File | Save As Web Page
    4.     Open the Web page you just created in Reports Builder
    5.     Double-click on Web Source node to display the HTML code for the Excel spreadsheet
    6.     Note how Excel generated HTML and XML code for the spreadsheet you created. Reports Builder also adds its own JSP tags
    7.     Add the Data Source An SQL Query
    8.     Modify the Web Source. Now that youve written the query, you can modify the Web source to tell Reports Builder to display your report in Excel.
    9.     Click on the Web Source icon in the toolbar.
    10.     To force the browser to open MS Excel it is necessary to change the HTTP Content Type to a specific MIME Type:
    application/vnd.ms-excel
         Insert the following line immediately before the <rw:report id=report> tag
              <%@ page contentType=application/vnd.ms-excel %>
         (This is a standard JSP directive to set a MIME Type (Content Type) )
    11.     To respect Excel format, you should delete the blank lines above the <html> tag.
    12.     Now, use Oracle 9i Reports JSP tags to add the data retrieved by your SQL Query to the report.
    13.     Search for the sample line of data you added to your Excel spreadsheet
    14.     Each line is saved as an HTML Table Row tag ( <tr> ).
    15.     Each column is mapped as an HTML Table Data tag ( <td> ).
    16.     Using Reports JSP Tags, add a Reports repeating frame tag to loop around the Data Model group.
    17.     To help, show the Object navigator next to the Web Source Window. All group information is now visible in the Object Navigator
    18.     Enclose the sample line of code in the Web source with the Reports9i JSP repeating tag.
    Use from menu Insert | Repeating Frame at beginning of sample
    Move the closing repeating tag after the </tr> tag.
    Start of the repeating tag would be
    <rw:foreach id=foreach src=>
    Ending of the repeating frame would be
    </rw:foreach>
    19.     In the opening of the repeating tag (<for each>), add the name of the group the tags enclose. JSP custom tags require a unique identifier.
    For example: <rw:foreach id=gEmpNoId src=G_EMPNO>
    20.     Now, map the cells of the Excel spreadsheet to the corresponding field from your data model.
    Select on the data value. From menu select Insert | Field. The source of the tag is the name of the field in the query.
    21.     Repeat the operation for each field of the report. Note: do not forget to specify a unique identifier for each field.
    22.     The code now contains a repeating frame. You have also mapped each cell in the Excel spreadsheet to the corresponding field in the data model
    23.     Save the report as a Reports JSP. You can test the report using the Run Web Layout icon in the toolbar
    24.     The execution of a Web Layout report from Reports Builder creates a temporary HTML file and launches the browser. The browser does not launch Excel because the document is saved as an HTML file. To launch Excel from the browser you need to test it from Reports Server.
    25.     In order to have the report appear inside Excel, you need to execute it with the Reports Server under OC4J. To do this you need to:
    First, start an OC4J instance from Oracle 9iDS see How to Execute Reports Services from Oracle 9iDS on OTN. Then, copy the JSP to a directory. For example: $IDS_HOME/reports/j2ee/reports_ids/web/test
    26.     Enter the URL to execute the jsp. The JSP is executed from an OC4J instance.
    http://reports9iTestServer:8888/reports/test/ListOfEmployees.jsp?userid=scott/tiger@ora901
    27. The browser launches Microsoft Excel and displays the data from your report.

  • Auto Expand Html table when we paster data from Microsoft Excel sheet

    hi,
    I need copied data to my Html table.
    Actual requirement is like that when i copy selected rows with selected columns from Microsoft excel sheet and press "ctlr v" on my jsp page then table on jsp must be auto expand as data in excel sheet.
    Take an example.
    I copy 4 rows with 3 columns from excel sheet.
    I have JSP page with 1 row and 3 columns.
    when i press "ctrl v" on first cell of my jsp table then table should be auto expand to accommodate 4 rows of excel sheet.
    here i have some of the code which is near to this, this code just copy past only one row, but i need multiple rows.
    If need then please refer below code and if possible then give me the solution to auto expand HTML table on JSP
    Code to copy paste cell in to HTML Table
    <form>
    <table>
    <tr>
    <td><input type="text" name="t1_0" onchange="formatCells(this.value,'t1')"></td>
    <td><input type="text" name="t1_1"></td>
    <td><input type="text" name="t1_2"></td>
    <td><input type="text" name="t1_3"></td>
    <td><input type="text" name="t1_4"></td>
    </tr>
    <tr>
    <td><input type="text" name="t2_0" onchange="formatCells(this.value,'t2')"></td>
    <td><input type="text" name="t2_1"></td>
    <td><input type="text" name="t2_2"></td>
    <td><input type="text" name="t2_3"></td>
    <td><input type="text" name="t2_4"></td>
    </tr>
    </table>
    </form>
    <script type="text/javascript">
    function formatCells(xls,group){
    var arrGroup = xls.split(/\t/gi);
    for(var i=0;i<arrGroup.length;i++){
    document.forms[0].elements[group + "_" + i].value = arrGroup;
    </script>
    Thanks
    Chintan Patel

    Hi Ross,
    >> In our testing environment using both Excel 2010 and 2013 this file is imported successfully, so we cannot replicate.
    I suspect it is caused by the difference of web server security settings.
    KB: Error message when you use Web query to a secure Web page (HTTPS://) in Excel: "Unable to open"
    Hope it will help.
    By the way, this forum is mainly for discussing questions about Office Development (VSTO, VBA and Apps for Office .etc.). For Office products feature specific questions, you could consider posting them on
    Office IT Pro forum or Microsoft Office Community.
    Regards,
    Jeffrey
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Unable to display double values in Excel sheet using JExcel API

    Hi
    I am writing code to generate report in the form of Excel Sheet using JExcel API.
    Everything is going fine but whenever I want to put some double values in a cell it is only showing 2 decimal places. My problem is "I want to show upto five decimal places".
    Any kind of reply might help me lot.
    Thank U.

    If you enable the submit zero option, it still happens? This is a new feature on the display tabl
    #NumericZero Enhancements
    To display a numeric zero in place of an error message, you can enter #NumericZero in any of the three Replacement text fields. When you use the #NumericZero option:
    · Excel formatting for the cell is retained.
    · All calculations with dependency on the cell will compute correctly and will take the value of this cell as zero.
    · This numeric zero is for display only. When you submit, the zero value is NOT submitted back to the data source.
    You cannot set display strings for cells that contain an invalid member or dimension name (metadata error). Metadata errors produce standard descriptive error messages.
    Errors are prioritized in the following order from highest to lowest. The error message for a higher-priority error takes precedence over that for a lower-priority error.
    1. (Highest) Metadata errors
    2. #No access
    3. #Invalid/Meaningless
    4. #No data\Missing

  • Can we create Multi Tabbed excel Sheet using Crystal Reports 2008

    Hi,
      We want to create a Crystal Report which will export the output as multiple Tab's ( we can use sub reports).  Can we create a Multi Tabbed excel Sheet using Crystal Reports 2008 ( not  Crystal reports Basic 2008). Please share any information/links on how to do that.
    Also if it is not supported please let us know which version supports it.
    Thanks,
    Vasu

    At least one of the 3rd-party Crystal Reports Desktop Scheduling tools listed at: http://www.kenhamady.com/bookmarks.html provides that functionality.  It allows you to burst a single report so that each Group at level 1 becomes a separate tab.  You can control the tab names (and tab colors) via fields/formulas inside the report.
    You can also automate the process of exporting to (and also replacing or appending to) specified tabs inside existing workbooks.

  • How to run Excel Macros using JDBC-ODBC

    Hi,
    I want to run the excel macros in the excel file, after I connected to excel file, using JDBC-ODBC bridge.
    How macros treated here?
    Help needed please..........
    - Ramesh

    How to run Excel Macros using JDBC-ODBCYou don't.
    As my fuzzy understanding goes.....
    Macros (excel, word, etc) run via a "OLE" extension of the script host system.
    So the only way to run them is via the OLE interface. That has nothing to do with ODBC. You can write your own JNI to do that, or you might get lucky and find that someone else has written a java library to do it for you.

  • Is it possible to create Excel Sheet using OLE automation in App server

    Hi,
       Is it possible to create Excel Sheet using OLE automation in Application server(Open Dataset)
    Thanks in advance...

    Unless your application server is on Windows OS, or it is connected to a Windows server by RFC. What is the requirement exactly, I don't understand?

  • Closing an excel sheet using active X%3F

    I am working with report generation toolkit.
    Before generating the report I'm trying to close all the excel sheets using Active X. At times the excel application gets closed without asking for the save or dont save option.
    What change should I do in the code?
    Please find the attached code
    Solved!
    Go to Solution.
    Attachments:
    PRJA1832_Dispose all Excel.vi ‏15 KB

    Hi,
         Thanks for the help.
    The VI is still not consistent at times. It closes without saving even if I'm using display alerts. I'm also getting an error when i keep running the code. And I think the error is because the excel sheet is maximised and I'm running the code. Please find the attached snapshot of the error.
    Regards
    Hridhya
    Attachments:
    Report disable alerts.png ‏51 KB

Maybe you are looking for