B4J Question jSQL and postgres

Pedro Caldeira

Active Member
Licensed User
Longtime User
Hello,
I am trying to reference a postgres database with jSQL and i get the following error:


B4X:
Waiting for debugger to connect...
Program started.
Error occurred on line: 57 (Main)
java.lang.RuntimeException: Class not found: org.postgresql.driver
Are you missing an #AdditionalJar attribute setting?
    at anywheresoftware.b4j.objects.SQL.Initialize2(SQL.java:54)
    at anywheresoftware.b4j.objects.SQL.Initialize(SQL.java:45)
    at b4j.example.main._initsql(main.java:174)
    at b4j.example.main._appstart(main.java:101)
    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.runMethod(Shell.java:613)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:231)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:159)
    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.BA.raiseEvent2(BA.java:90)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:93)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:77)
    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)

I am referencing the additional jar with

B4X:
#AdditionalJar: postgresql-42.2.2 ' the jar is in the additional libs folder

and

B4X:
sub initSQL
   
dim Sql1 as SQL
    dim ConnectionString as string=$"jdbc:postgresql://${Database_Ip}:${Database_Port}/${Database_Name}"$
    Sql1.Initialize("org.postgresql.driver", ConnectionString)

end sub

what I am doing wrong ?
 

OliverA

Expert
Licensed User
Longtime User
Sql1.Initialize("org.postgresql.driver", ConnectionString)
Probably just a capitalization issue (it matters in Java)
B4X:
Sql1.Initialize("org.postgresql.Driver", ConnectionString)
 
Upvote 0
Top