B4J Question How to open access file with password

universengo

Member
Hello friends!
How can i open the access database file with password by b4j code?
I tried this code. But have error
B4X:
gSQL.Initialize("net.ucanaccess.jdbc.UcanaccessDriver", "jdbc:ucanaccess://" & DBFileDir &"\" & DBFile & ";showSchema=true; password=12345")
Please help me
 
Last edited:

universengo

Member
Use Initialize2 and pass the username and password as the last two parameters.
Thanks, Erel
I use this code but error (my data file is *.accdb file)
My code:
B4X:
gSQL.Initialize2("net.ucanaccess.jdbc.UcanaccessDriver", "jdbc:ucanaccess://" & DBFileDir &"\" & DBFile & ";showSchema=true","","123456")
with user = "" and pass = "123456".
My error code:
B4X:
Waiting for debugger to connect...
Program started.
Error occurred on line: 88
net.ucanaccess.jdbc.UcanaccessSQLException: UCAExc:::4.0.4 Decoding not supported.  Please choose a CodecProvider which supports reading the current database encoding.
    at net.ucanaccess.jdbc.UcanaccessDriver.connect(UcanaccessDriver.java:231)
    at java.sql.DriverManager.getConnection(DriverManager.java:664)
    at java.sql.DriverManager.getConnection(DriverManager.java:247)
    at anywheresoftware.b4j.objects.SQL.Initialize2(SQL.java:57)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:676)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:240)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
    at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)
    at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:78)
    at b4j.example.main.start(main.java:38)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$161(LauncherImpl.java:863)
    at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$174(PlatformImpl.java:326)
    at com.sun.javafx.application.PlatformImpl.lambda$null$172(PlatformImpl.java:295)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$173(PlatformImpl.java:294)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$null$147(WinApplication.java:177)
    at java.lang.Thread.run(Thread.java:748)
Caused by: com.healthmarketscience.jackcess.impl.UnsupportedCodecException: Decoding not supported.  Please choose a CodecProvider which supports reading the current database encoding.
    at com.healthmarketscience.jackcess.impl.DefaultCodecProvider$UnsupportedHandler.decodePage(DefaultCodecProvider.java:126)
    at com.healthmarketscience.jackcess.impl.PageChannel.readPage(PageChannel.java:237)
    at com.healthmarketscience.jackcess.impl.UsageMap.read(UsageMap.java:130)
    at com.healthmarketscience.jackcess.impl.PageChannel.initialize(PageChannel.java:117)
    at com.healthmarketscience.jackcess.impl.DatabaseImpl.<init>(DatabaseImpl.java:532)
    at com.healthmarketscience.jackcess.impl.DatabaseImpl.open(DatabaseImpl.java:401)
    at com.healthmarketscience.jackcess.DatabaseBuilder.open(DatabaseBuilder.java:252)
    at net.ucanaccess.jdbc.DefaultJackcessOpener.open(DefaultJackcessOpener.java:32)
    at net.ucanaccess.jdbc.DBReference.<init>(DBReference.java:169)
    at net.ucanaccess.jdbc.DBReferenceSingleton.loadReference(DBReferenceSingleton.java:51)
    at net.ucanaccess.jdbc.UcanaccessDriver.connect(UcanaccessDriver.java:91)
    ... 26 more
Please help me!
 
Last edited:

Erel

Administrator
Staff member
Licensed User
Can you upload a small password protected access database (with the user name and password)?
 
Top