sqlite java delete 时出现database disk image is malformed

pei322 2012-07-04 03:48:26
环境 :JDK1.6
JAVA APPLICATION 开发
SQLite3
问题: 在用JAVA调用“DELETE FROM 表名 ”时数据库文件就出错,出错信息“database disk image is malformed”。
请高手解答:
1、是何原因造成这个问题?
2、怎么解决 这个问题。
...全文
1210 20 打赏 收藏 转发到动态 举报
写回复
用AI写文章
20 条回复
切换为时间正序
请发表友善的回复…
发表回复
suixin0521 2014-11-21
  • 打赏
  • 举报
回复
是数据库的某个表坏了,修复下数据库就行了,http://rimland.blog.163.com/blog/static/883254620128281588906/
snakech 2013-02-21
  • 打赏
  • 举报
回复
朋友,你怎么解决的啊,给点提示啊,我也遇见一样的问题了,换什么驱动啊
pei322 2012-07-05
  • 打赏
  • 举报
回复
问题已经解决,是JDBC驱动的问题。换了个驱动问题解决了。感谢wwwwb的热心帮助。
pei322 2012-07-04
  • 打赏
  • 举报
回复
杯具了,DROP TABLE也是这个错误。可能要找找JDBC驱动或执行过程中的问题了。
pei322 2012-07-04
  • 打赏
  • 举报
回复
谢谢,我先试试Drop Table了。先看看解决问题。然后再仔细研究一下原因。
wwwwb 2012-07-04
  • 打赏
  • 举报
回复
[Quote=引用 14 楼 的回复:]

试了一下,问题依旧。
[/Quote]
算了,直接DROP TABLE TT,再建立
pei322 2012-07-04
  • 打赏
  • 举报
回复
试了一下,问题依旧。
wwwwb 2012-07-04
  • 打赏
  • 举报
回复
sqlite faq:
(21) What is an SQLITE_CORRUPT error? What does it mean for the database to be "malformed"? Why am I getting this error?

An SQLITE_CORRUPT error is returned when SQLite detects an error in the structure, format, or other control elements of the database file.

SQLite does not corrupt database files, except in the case of very rare bugs (see DatabaseCorruption) and even then the bugs are normally difficult to reproduce. Even if your application crashes in the middle of an update, your database is safe. The database is safe even if your OS crashes or takes a power loss. The crash-resistance of SQLite has been extensively studied and tested and is attested by years of real-world experience by millions of users."

That said, there are a number of things that external programs or bugs in your hardware or OS can do to corrupt a database file. Details can be found in the discussions on the atomic commit and locking support in SQLite as well as in the mailing list archives.

Your can use PRAGMA integrity_check to do a thorough but time intensive test of the database integrity.

Your can use PRAGMA quick_check to do a faster but less thorough test of the database integrity.

Depending how badly your database is corrupted, you may be able to recover some of the data by using the CLI to dump the schema and contents to a file and then recreate. Unfortunately, once humpty-dumpty falls off the wall, it is generally not possible to put him back together again.
wwwwb 2012-07-04
  • 打赏
  • 举报
回复
打开事务试试:
BEGIN TRANSACTION;
delete ....
COMMIT TRANSACTION;
pei322 2012-07-04
  • 打赏
  • 举报
回复
不行就只有试试 drop table了。我是在WIN7,64位机器上运行的。数据是直接存在硬盘上的,所以空间和坏道的问题应该都不存在。只要是表里面有数据,删除时没有产生任何错误,删除语句执行好,数据库就挂了。郁闷。
wwwwb 2012-07-04
  • 打赏
  • 举报
回复
你直接DROP TABLE TT,再建立1个不行?
wwwwb 2012-07-04
  • 打赏
  • 举报
回复
你的运行环境?
你的SQLITE文件没有存贮在SD上吧?
检查一下磁盘是否有坏磁道,可换个磁盘试试。
pei322 2012-07-04
  • 打赏
  • 举报
回复
谢谢,我主要还是要解决问题。因为要先删除表后再进行表的插入。现在只要删除表数据就出错。后面的操作都不做也出错。所以很奇怪,想找到问题的原因。
wwwwb 2012-07-04
  • 打赏
  • 举报
回复
http://www.kinook.com/Forum/showthread.php?p=9106
下载1个修复软件试试
wwwwb 2012-07-04
  • 打赏
  • 举报
回复
那就只有用备份了,SQLITE没有提供数据库修复软件
pei322 2012-07-04
  • 打赏
  • 举报
回复
无法修复,导 出后的SQL文件里面也是database disk image is malformed这个错误。
wwwwb 2012-07-04
  • 打赏
  • 举报
回复
试试能否导出数据库:
首先导出数据
sqlite3 tt
sqlite>.output old.sql
sqlite>.dump
sqlite>.quit

再倒入到一个新库中
sqlite3 newtt
sqlite>.read old.sql
sqlite>.quit
pei322 2012-07-04
  • 打赏
  • 举报
回复
1、磁盘空间还有很大,不是磁盘或断电的问题。
2、PRAGMA integrity_check;结果一样,没有任何信息只有错误database disk image is malformed
wwwwb 2012-07-04
  • 打赏
  • 举报
回复
sqlite>PRAGMA integrity_check;

提示什么错误信息
wwwwb 2012-07-04
  • 打赏
  • 举报
回复
检查 磁盘空间、确定数据库文件是否损坏(写入数据过程中突然掉电、非正常退出程序)

2,209

社区成员

发帖
与我相关
我的任务
社区描述
其他数据库开发 其他数据库
社区管理员
  • 其他数据库社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧