Excel DB:操作必须使用可更新的查询 [英] Excel DB: Operation must use an updateable query

查看:408
本文介绍了Excel DB:操作必须使用可更新的查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于jdbc程序,im需要连接一个excel数据库。连接成功,但是输入值,它给出操作必须使用可更新的查询异常。

for a jdbc program, im required to make a connection an excel database. the connection is successfully made but wen entering values into it, its giving an "Operation must use an updateable query" exception.

这里是代码:

        String url="jdbc:odbc:Sample";   //CHANGE THE DATABASE NAME
        Connection conn= DriverManager.getConnection(url,"","");
        PreparedStatement prepstat = null;
        String insert="INSERT INTO [Sheet1$] ([AccountID], [ProjectID], [PositionID]) VALUES (?,?,?)";
        prepstat= conn.prepareStatement(insert);
        prepstat.setString(1, accountID);  
        prepstat.setString(2, projectID);
        prepstat.setString(3, positionID);
        prepstat.executeUpdate();   // this is where the exception occurs


推荐答案

我不熟悉JDBC,但是ODBC将是:

I am not familiar with JDBC, but ODBC would be:

"Driver={Microsoft Excel Driver (*.xls)};" & _
"DBQ=C:\MyFolder\MyWorkbook.xls; ReadOnly=False;"

默认情况下,Excel是只读的: http://support.microsoft.com/kb/257819

Excel is read-only by default: http://support.microsoft.com/kb/257819

这篇关于Excel DB:操作必须使用可更新的查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆