Accessing an Excel sheet from a java application
843853Aug 19 2001 — edited Dec 6 2007Hello Sir,
I face a peoblem in writing data from a java application to an Excel Sheet. I've made an ODBC connection with the excel sheet and I wrote a java application to insert some data to that sheet via the ODBC driver but it doesn't wrok. The "INSERT..." and "UPDATE.." statements doesn't work although the "SELECT.." starement works well.
the following is my java application:
/////////////////////////////////////////////////////////
import java.io.*;
import java.sql.*;
public class TestExcel2{
public static void main(String[] args){
Connection connection = null;
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection( "jdbc:odbc:ExcelDSN" );
PreparedStatement pr=con.prepareStatement("insert into[Sheet1$](marwan) values(?)");
pr.clearParameters();
pr.setInt(1, 12);
pr.executeUpdate();
con.close();
}catch(Exception ex) {
System.err.print("Exception: ");
System.err.println(ex.getMessage());
}
}
}
////////////////////////////////////////////////////////
the folowing error appears when executing the application.
///////////////////////////////////////////////////
Exception [microsoft] [ODBC Excel Driver] Operation must use an updateable query.
/////////////////////////////////////////////////////
Could any one please help me in solving the problem??
Best regards
Mawan dardounh