B4J Question Connect B4J to SQL Server Database

Hi Guys,

Apologies as I am quite new to this and have had a look around and cannot seem to find how to connect a B4J project to SQL Server. I assume on the SQL server side there is some work that needs to be done around accepting remote connections as well as some port forwarding? Also what's involved on the B4J side? Any tips or links would be greatly appreciated. Thanks
 
Hi Erel I went through that link however is there anything around connecting to a remote SQL Server? Or can I use the code below from that thread and replace the localhost with the external IP address of the SQL server?

#Region Project Attributes#MainFormWidth: 600#MainFormHeight: 400#AdditionalJar: jtds-1.3.1.jar#End RegionSub Process_GlobalsPrivate sql1 AsSQLEnd SubSub AppStart (Form1 AsForm, Args() AsString)Try
sql1.Initialize("net.sourceforge.jtds.jdbc.Driver","jdbc:jtds:sqlserver://localhost:1433/NombreBD;user=xxx;password=yyy")CatchLog("Error de conexión con la BD "EndTry
End Sub
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Please use [code]code here...[/code] tags when posting code.

Or can I use the code below from that thread and replace the localhost with the external IP address of the SQL server?
Yes.

A better solution is to use InitializeAsync for remote databases.
And the best solution is to use ConnectionPool from jServer library.
 
Upvote 0
Please use [code]code here...[/code] tags when posting code.


Yes.

A better solution is to use InitializeAsync for remote databases.
And the best solution is to use ConnectionPool from jServer library.
Thanks Erel basically I'm trying to populate a table in my form with data from my remote SQL Server database. Is there any advice you have for this type of project?
I don't need to upload/post data back into the database only read from it.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…