B4J Question Problem with MYSQL connection

ThorstenStueker

Member
Licensed User
B4X:
#Region Project Attributes
    #MainFormWidth: 600
    #MainFormHeight: 600
    
  #AdditionalJar: mysql-connector-java-5.1.47-bin.jar
  
#End Region

Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
    
    Private Button1 As B4XView
    Private oldbase As SQL
    
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    oldbase.Initialize2("com.mysql.jdbc.MysqlDataSource", "jdbc:mysql://192.168.178.26:3306/HD2000_production?characterEncoding=utf8", "thorsten", "rachel123")
    
    MainForm = Form1
    MainForm.RootPane.LoadLayout("Layout1")
    MainForm.Show
End Sub

Sub Button1_Click
    
End Sub

with Errormessage
Waiting for debugger to connect...
Program started.
Fehler in Zeile: 19 (Main)
java.lang.RuntimeException: Class not found: com.mysql.jdbc.MysqlDataSource
Are you missing an #AdditionalJar attribute setting?
at anywheresoftware.b4j.objects.SQL.Initialize2(SQL.java:56)
at b4j.example.main._appstart(main.java:74)
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:632)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:237)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
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: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$8(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$7(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$5(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$6(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$3(WinApplication.java:177)
at java.lang.Thread.run(Thread.java:748)
 

ThorstenStueker

Member
Licensed User
Got a solution working with initialize async

#AdditionalJar: mysql-connector-java-5.1.47-bin.jar

#End Region

Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Dim sql1 As SQL
Private Button1 As B4XView
Private oldbase As SQL

End Sub

Sub AppStart (Form1 As Form, Args() As String)

sql1.InitializeAsync("MySQL", "com.mysql.jdbc.Driver", "jdbc:mysql://127.0.0.1/HDXXXXXXXtion", "tXXXXXXn", "rXSXXXXXXX3")
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
Btw, this had nothing to do with initialize va initializeasync. The driver class string was incorrect in the first post
 
Upvote 0
Top