-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExperiment.java
More file actions
38 lines (28 loc) · 1.96 KB
/
Experiment.java
File metadata and controls
38 lines (28 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package com.almworks.sqlite4java;
import static com.almworks.sqlite4java.SQLiteConstants.SQLITE_OPEN_CREATE;
import static com.almworks.sqlite4java.SQLiteConstants.SQLITE_OPEN_READWRITE;
public class Experiment {
public static void main(String[] args) {
System.loadLibrary("sqlite");
System.out.println("_SQLiteSwigged.sqlite3_libversion()=" + _SQLiteSwigged.sqlite3_libversion());
System.out.println("_SQLiteSwigged.sqlite3_libversion_number()=" + _SQLiteSwigged.sqlite3_libversion_number());
System.out.println("_SQLiteSwigged.sqlite3_threadsafe()=" + _SQLiteSwigged.sqlite3_threadsafe());
System.out.println("_SQLiteSwigged.sqlite3_memory_used()=" + _SQLiteSwigged.sqlite3_memory_used());
_SQLiteManual sqLiteManual = new _SQLiteManual();
SWIGTYPE_p_sqlite3 db = sqLiteManual.sqlite3_open_v2("test.db", SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE);
System.out.println("_SQLiteManual.sqlite3_open_v2()=" + sqLiteManual.getLastReturnCode() + "," + db);
int rc = _SQLiteManual.sqlite3_exec(db, "create table if not exists xxx (xxx)", null);
System.out.println("_SQLiteSwigged.exec()=" + rc);
String[] parseError = {null};
rc = _SQLiteManual.sqlite3_exec(db, "create table if not exists yyy (yyy)", parseError);
System.out.println("_SQLiteSwigged.exec()=" + rc + ", parseError=" + parseError[0]);
rc = _SQLiteManual.sqlite3_exec(db, "create blablabla; select * from xxx;", parseError);
System.out.println("_SQLiteSwigged.exec()=" + rc + ", parseError=" + parseError[0]);
SWIGTYPE_p_sqlite3_stmt stmt = sqLiteManual.sqlite3_prepare_v2(db, "insert into xxx (xxx) values(?)");
System.out.println("_SQLiteManual.sqlite3_prepare_v2()=" + sqLiteManual.getLastReturnCode() + ",stmt=" + stmt);
rc = _SQLiteSwigged.sqlite3_finalize(stmt);
System.out.println("_SQLiteManual.sqlite3_prepare_v2()=" + rc + ",stmt=" + stmt);
rc = _SQLiteSwigged.sqlite3_close(db);
System.out.println("_SQLiteSwigged.sqlite3_close()=" + rc);
}
}