Hi
Is it possible to make databse apps based on SQlite ?
Thanks
Elico
Elico,
Here's the general idea. I took snippets from a production application.
If any questions, let us know, thanks.
*************************************
Pull the sqlite driver, from
https://bitbucket.org/xerial/sqlite-jdbc/downloads
, and put it in your classpath (Projects/References (Classpath)...F1)
The one I used was sqlite-jdbc-3.7.2.jar.
|
Source code
|
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
'...
'...
'...
Import org.sqlite.JDBC
'...
'...
'...
Public sqlSQLiteInstance As groovy#sql#Sql
'...
'...
'...
Dim bResult As Boolean
Dim sSqliteFileName As String
Dim sTableName As String
Dim sSqlInsert As String
Dim sSqlInsert02 As String
Dim rsSQLite As ResultSet
'...
'...
'...
sSqliteFileName = "c:\Projects_Programming\Jabaco\ImportFromCSV\Whatthe.DB"
sTableName = "Whatever"
sSqlInsert = "..." (Some Insert statement)
sSqlInsert02 = "..." (Another Insert statement)
'...
'...
'...
sqlSQLiteInstance = groovy#sql#Sql.newInstance("jdbc:sqlite:" + sSqliteFileName, "org.sqlite.JDBC" )
sqlSQLiteInstance.execute( "PRAGMA synchronous=OFF" )
'...
'...
'...
rsSQLite = sqlSQLiteInstance.getConnection.getMetaData().getColumns( Null, Null, sTableName, Null )
'...
'...
'...
bResult = rsSQLite.next()
Do Until Not bResult
sColumnName = rsSQLite.getString( "COLUMN_NAME" )
sColumnType = rsSQLite.getString( "TYPE_NAME" )
system.out.println( sColumnName )
system.out.println( sColumnType )
bResult = rsSQLite.next()
Loop
'...
'...
'...
sqlSQLiteInstance.execute( "BEGIN TRANSACTION" )
sqlSQLiteInstance.execute( sSqlInsert )
sqlSQLiteInstance.execute( sSqlInsert02 )
sqlSQLiteInstance.execute( "COMMIT TRANSACTION" )
'...
'...
'...
sqlSQLiteInstance.close()
'...
'...
'...
|