Tag Archives: Sqlite

Solution to SQLite error database is locked

Connect the SQLite database with firedac, bind the field name to the space tdbedit, and the following statement will report an error when modifying its value

procedure   TForm1.Button3Click(Sender:   TObject);
begin

  fdquery.Edit;
  fdquery.FieldByName(‘name’).AsString:=’test2′;
  fdquery.post;    // An error is reported here  [ FireDAC][Phys][SQLite]   ERROR:   database   is   locked.   It’s the same with refresh

end;

 

Set connection parameters for SQLite   LockingMode=normal   Solved

Sqlite Error:com.intellij.execution.ExecutionException: Exception in thread “main” java….

Error when deleting database migrations
Reported error: com.intellij.execution.ExecutionException: Exception in thread “main” java.lang.ClassNotFoundException: org.sqlite.JDBC

Exception in thread “main” java.lang.ClassNotFoundException: org.sqlite.JDBC
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(Unknown Source)
at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Unknown Source)
at com.intellij.database.remote.RemoteJdbcServer.main(RemoteJdbcServer.java:14).
com.intellij.execution.ExecutionException: Exception in thread “main” java.lang.ClassNotFoundException: org.sqlite.JDBC
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(Unknown Source)
at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Unknown Source)
at com.intellij.database.remote.RemoteJdbcServ… (show balloon)

 

 

Solution:

Install the driver

Using SQLite to show undefined reference to ` SQLite3_ open’…

Assuming you have compiled and installed Sqlite correctly, write a test program to test.

#include <stdlib.h>

#include <stdio.h>

#include “sqlite3.h”

int main(void)

{

sqlite3 *db=NULL;

char *zErrMsg = 0;

int rc;

rc=sqlite3_open(“test1.db”,&db);

if(rc)

{

fprintf(stderr,”Can’t open database: %s\n”,sqlite3_errmsg(db));

sqlite3_close(db);

exit(1);

}

else printf(“open mydata successfully!\n”);

sqlite3_close(db);

return 0;

}

When compiling with GCC there is always an error, the compile command is as follows

gcc -static -o hello -lsqlite3 -L /usr/local/lib -I/usr/local/include hello.c

The error message is as follows

/tmp/ccKeKpX9.o(.text+0x37): In function `main’:

: undefined reference to `sqlite3_open’

/tmp/ccKeKpX9.o(.text+0x51): In function `main’:

: undefined reference to `sqlite3_errmsg’

/tmp/ccKeKpX9.o(.text+0x73): In function `main’:

: undefined reference to `sqlite3_close’

/tmp/ccKeKpX9.o(.text+0x9b): In function `main’:

: undefined reference to `sqlite3_close’

collect2: ld returned 1 exit status

The error is not in SQLITE nor in your program at all, but in GCC. the compilation parameters of Gcc are in order. The correct compile command is

gcc -o hello -L /usr/local/lib -I/usr/local/include -static hello.c -lsqlite3