B4J Question How to connect B4J to SQL Server

BarryW

Active Member
Licensed User
Longtime User
Hi masters. How to connect b4j to a sql server

Here is my connection in VB6

"Provider = sqloledb;" & _
"Persist Security Info=False;" & _
"Data Source=192.168.1.244;" & _
"Initial Catalog=nino;" & _
"User ID=developer;" & _
"Password=developer;"

Tnx...
 

Eumel

Active Member
Licensed User
Longtime User
You need the MySQL/J connector.
You need to check the jSQL Library

In Project Attributes add

B4X:
#AdditionalJar: mysql-connector-java-5.1.29-bin.jar

Then you initialize the SQL Object.

B4X:
Private SQL1 as SQL  'in Class Globals or Process Globals

SQL1.Initialize2("com.mysql.jdbc.Driver", "jdbc:mysql://localhost/test?characterEncoding=utf8", "username", "passwort")

That´s it
 
Upvote 0

BarryW

Active Member
Licensed User
Longtime User
I already download as driver file. It as .jar file named jtds-1.3.1.jar

Now how i will initialize it?. It has a username and password.

Tnx
 
Upvote 0

BarryW

Active Member
Licensed User
Longtime User
Here is my code

JSQL.Initialize("net.sourceforge.jtds.jdbc.Driver", "jdbc:jtds:sqlserver://192.168.1.244/nino/developer/developer")

Now here is my error:

Program started.
Error occurred on line: 13 (main).
java.sql.SQLException: I/O Error: SSO Failed: Native SSPI library not loaded. Check the java.library.path system property.
at net.sourceforge.jtds.jdbc.TdsCore.login(TdsCore.java:654)
at net.sourceforge.jtds.jdbc.JtdsConnection.<init>(JtdsConnection.java:371)
at net.sourceforge.jtds.jdbc.Driver.connect(Driver.java:184)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
at anywheresoftware.b4j.objects.SQL.Initialize2(SQL.java:56)
at anywheresoftware.b4j.objects.SQL.Initialize(SQL.java:45)
at b4j.example.main._appstart(main.java:58)
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:497)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:563)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:221)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:156)
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:497)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:82)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:84)
at b4j.example.main.main(main.java:29)
Caused by: java.io.IOException: SSO Failed: Native SSPI library not loaded. Check the java.library.path system property.
at net.sourceforge.jtds.jdbc.TdsCore.sendMSLoginPkt(TdsCore.java:1963)
at net.sourceforge.jtds.jdbc.TdsCore.login(TdsCore.java:617)
... 22 more
Program terminated (StartMessageLoop was not called).
 
Upvote 0
Top