B4J Library [B4X] [B4XLib] SD_SQL (direct access to MySQL, MariaDB, MS SQL, FireBird)

Star-Dust

Expert
Licensed User
Longtime User
I believe the error indicates that the server did not respond to that address / port.

If you do a Google search you see that it is often generated by the firewall or by wrong parameters. I can't help you much as you have to do some tests locally to understand the problem
 

Alex.G

Member
Why in debug mode it runs ok?
 

Star-Dust

Expert
Licensed User
Longtime User
Why in debug mode it runs ok?
I can't give you answers on everything, I don't have enough information I guess it could be a permissions issue.
The error indicates that there is no response from the server because it cannot be reached.

What version of Android do you have?
 

Alex.G

Member
I can't give you answers on everything, I don't have enough information I guess it could be a permissions issue.
The error indicates that there is no response from the server because it cannot be reached.

What version of Android do you have?
Thanks Star-Dust, I'm trying and retrying 'cause I've to understand and resolve this problem.

Tested on Android 6, 7 and 11, same result: Debug mode OK, Release mode connection error.
What's the difference between these two mode?
No one had matter this problem?

I can try with an android emulator on Windows, can you advise me one?
 

Alex.G

Member
Try to disable this check: Workaround the NetworkOnMainThread exception
It is only applied in release mode.
Hi Erel,
thanks for trick.

Problem solved adding these two rows to Manifest file:
B4X:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_S TATE" />

Let's hope this can help someone like me.

Now I want to try Erel's Library jRDC2
 

Star-Dust

Expert
Licensed User
Longtime User
I can't give you answers on everything, I don't have enough information I guess it could be a permissions issue.
As I wrote it could be a permission issue
 

MrKim

Well-Known Member
Licensed User
Longtime User
(I am working on a version for b4i, but it is only obtainable with a wrap. it will take a long time because I have never written a line in objective-c).
I don't know if you are still planning to do B4i, but if you are, I found this:


It would be great, then we would have a complete B4x solution for directly connecting to SQL server DBs.
 

Star-Dust

Expert
Licensed User
Longtime User
It was planned, but I failed several attempts.

Thanks for pointing me to a possible solution. I'll work on it as soon as possible, but I'm not sure I know enough objective-c to be able to port this code to B4x
 

MrKim

Well-Known Member
Licensed User
Longtime User
It was planned, but I failed several attempts.

Thanks for pointing me to a possible solution. I'll work on it as soon as possible, but I'm not sure I know enough objective-c to be able to port this code to B4x
It would be , then we would have a complete B4X solution. I have written a class that can use either direct or jrdc - pass the same request. Then I could complete the circle.
 

Star-Dust

Expert
Licensed User
Longtime User
Update 0.07
  • Added the connect method
  • Added the connected field (status)
  • Examples updated
To avoid confusion the initialize command is split from the connect command. Some people confused the isInitilized field with isConnected. In addition, a Connected field has been added that allows you to know the status, each connection is equally raised an event that returns the status..
 
Hy,
maybe you can help me. When I do this query at SQL Studio ill get one result.
When I try to read this at B4A Ill get a error...


Dim query As String
query = MSSQL.ExecQuery("SELECT fVKNetto FROM dbo.tArtikel WHERE cBarcode='4019111013805' or cArtNr='4019111013805'")
Netto.Text = query
Log(query)

This error I get:

[main=null, nativers=(JtdsResultSet) net.sourceforge.jtds.jdbc.JtdsResultSet@11296b7f, starter=null

Thanks

Steven
 

DonManfred

Expert
Licensed User
Longtime User
Hy,
maybe you can help me. When I do this query at SQL Studio ill get one result.
1. You are posting to an old thread which is a mistake.
2. You are NOT using the Resultset correctly.

Create a new thread in the questionsforum for any Issue you have.
 

Star-Dust

Expert
Licensed User
Longtime User
The result of a query must be contained in a ResultSet. Only ExecQuerySingleResult could possibly be contained in a string, but this method has not been included in this library.
 

amorosik

Expert
Licensed User
1. You are posting to an old thread which is a mistake.
2. You are NOT using the Resultset correctly.

Create a new thread in the questionsforum for any Issue you have.

The question is directed connected with the post argument
If someone were to seek answers to problems relating to the initial post, they would easily find an answer by scrolling through the 3d
Why you wrote "is a mistake" ?
 

vecino

Well-Known Member
Licensed User
Longtime User
Hi, I am trying to display an image that is stored in a mysql blob field and I get this error:

(RuntimeException) java.lang.RuntimeException: Class instance was not initialized (sd_sql)

What am I doing wrong?
The text and numeric fields are displaying fine.
Thank you very much.

B4X:
    Dim cDirImage As String = File.DirInternal
    Dim cFileImage As String = "tempimage.jpg"

    Dim cSql As String = $"select jpgimg from ${MyTable} where id=${iIDregistroActual}"$

    Dim RS As SD_ResultSet = MYSQL.ExecQuery(cSql)      

    Dim img() As Byte = RS.GetBytes("JPGIMG")   '  ERROR on this line. !!!!!!!!!!

    If img.Length>0 Then
        Dim tempimagepath As String = File.Combine(cDirImage,cFileImage)
        File.WriteBytes(cDirImage,cFileImage,img)
        Dim html As String
        html = "<html><body><img src='file://" & tempimagepath & "' /></body></html>"
        Dim webview As WebView = Web
        webview.LoadHtml(html)  
    End If
 

vecino

Well-Known Member
Licensed User
Longtime User
Sorry, I copied the error line wrong, it is this one:


Surely it is better to create a new thread for more people to see.
Thank you very much.
 
Last edited:
Cookies are required to use this site. You must accept them to continue using the site. Learn more…