Hi, everyone.
I am using the Jdbc 3.36 driver,But it cannot open my encrypted database jtjz.db(Using sqlcipher in B4A can open this database normally).Please help me.
Code is as follows:
Dim co As Int=SQL1.ExecQuerySingleResult(sql)
Error when running to this line of code,The error message is as follows:
I am using the Jdbc 3.36 driver,But it cannot open my encrypted database jtjz.db(Using sqlcipher in B4A can open this database normally).Please help me.
Code is as follows:
B4X:
#AdditionalJar: sqlite-jdbc-3.36.0.2
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
xui.SetDataFolder("jtjz")
SQLDataBasePath=xui.DefaultFolder
SQLDateBaseName="jtjz.db"
If File.Exists(SQLDataBasePath,SQLDateBaseName)=False Then
File.Copy(File.DirAssets,SQLDateBaseName,SQLDataBasePath,SQLDateBaseName)
End If
Dim db As String=File.Combine(SQLDataBasePath,SQLDateBaseName)
Dim db1 As String=db.Replace("\","/")
Log(db1)
SQL1.Initialize("org.sqlite.JDBC",$"jdbc:sqlite:file:${db1}?cipher=sqlcipher&legacy=4&kdf_iter=256000&key=5678"$)
End Sub
Private Sub Button1_Click
Dim bt As String=TextField1.Text.Trim
Dim nr As String=TextArea1.Text
sql="select count(*) from jtcy"
Dim co As Int=SQL1.ExecQuerySingleResult(sql)
Log(co)
End Sub
Error when running to this line of code,The error message is as follows:
B4X:
Error occurred on line: 46 (B4XMainPage)
org.sqlite.SQLiteException: [SQLITE_NOTADB] File opened that is not a database file (file is not a database)
at org.sqlite.core.DB.newSQLException(DB.java:1030)
at org.sqlite.core.DB.newSQLException(DB.java:1042)
at org.sqlite.core.DB.throwex(DB.java:1007)
at org.sqlite.core.NativeDB.prepare_utf8(Native Method)
at org.sqlite.core.NativeDB.prepare(NativeDB.java:137)
at org.sqlite.core.DB.prepare(DB.java:257)
at org.sqlite.core.CorePreparedStatement.<init>(CorePreparedStatement.java:45)
at org.sqlite.jdbc3.JDBC3PreparedStatement.<init>(JDBC3PreparedStatement.java:30)
at org.sqlite.jdbc4.JDBC4PreparedStatement.<init>(JDBC4PreparedStatement.java:25)
at org.sqlite.jdbc4.JDBC4Connection.prepareStatement(JDBC4Connection.java:35)
at org.sqlite.jdbc3.JDBC3Connection.prepareStatement(JDBC3Connection.java:241)
at org.sqlite.jdbc3.JDBC3Connection.prepareStatement(JDBC3Connection.java:205)
at anywheresoftware.b4j.objects.SQL.ExecQuery2(SQL.java:365)
at anywheresoftware.b4j.objects.SQL.ExecQuerySingleResult2(SQL.java:420)
at anywheresoftware.b4j.objects.SQL.ExecQuerySingleResult(SQL.java:409)
at b4j.example.b4xmainpage._button1_click(b4xmainpage.java:117)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:629)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:234)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:111)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:100)
at anywheresoftware.b4a.BA$1.run(BA.java:236)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
at java.base/java.lang.Thread.run(Thread.java:832)