创建表时,sqlite数据库被锁定

时间:2016-01-26 20:44:51

标签: java sqlite

我运行这个简单的代码:

public static void main(String[] args) 
{
  Connection c = null;
  Statement stmt = null;
  try {
    Class.forName("org.sqlite.JDBC");
    c = DriverManager.getConnection("jdbc:sqlite:test.db");
    System.out.println("Opened database successfully");

    stmt = c.createStatement();
    String sql = "CREATE TABLE COMPANY " +
            "(ID INT PRIMARY KEY     NOT NULL," +
            " NAME           TEXT    NOT NULL, " +
            " AGE            INT     NOT NULL, " +
            " ADDRESS        CHAR(50enter code here), " +
            " SALARY         REAL)";
    stmt.executeUpdate(sql);
    stmt.close();
    c.close();
  } catch ( Exception e ) {
    System.err.println( e.getClass().getName() + ": " + e.getMessage() );
    System.exit(0);
}
System.out.println("Table created successfully");

我得到了这个例外

java.sql.SQLException: database is locked. 

它没有任何意义,它只是单个连接和DB上的一个操作。

有什么想法吗?

0 个答案:

没有答案