Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Accessing an Excel sheet from a java application

843853Aug 19 2001 — edited Dec 6 2007
Hello 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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 3 2008
Added on Aug 19 2001
18 comments
447 views