B4J Question How to open access file with password

Discussion in 'B4J Questions' started by universengo, Jul 22, 2019.

  1. universengo

    universengo Member

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

    Erel Administrator Staff Member Licensed User

    Does it work with unprotected "databases"?
     
    universengo likes this.
  3. universengo

    universengo Member

    My app is working with none password data.
    Now I would like to Protect my data.
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    Use Initialize2 and pass the username and password as the last two parameters.
     
    universengo likes this.
  5. universengo

    universengo Member

    Thanks, Erel
    I use this code but error (my data file is *.accdb file)
    My code:
    Code:
    gSQL.Initialize2("net.ucanaccess.jdbc.UcanaccessDriver""jdbc:ucanaccess://" & DBFileDir &"\" & DBFile & ";showSchema=true","","123456")
    with user = "" and pass = "123456".
    My error code:
    Code:
    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: Jul 23, 2019
  6. Erel

    Erel Administrator Staff Member Licensed User

    Can you upload a small password protected access database (with the user name and password)?
     
  7. universengo

    universengo Member

    I can't upload file because the web have a message not support extension file.
     
  8. Erel

    Erel Administrator Staff Member Licensed User

    Zip it first.
     
  9. universengo

    universengo Member

    Last edited: Jul 24, 2019
  10. Erel

    Erel Administrator Staff Member Licensed User

  11. universengo

    universengo Member

    Last edited: Jul 24, 2019
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice