B4J Library jSQL v1.20 - Asynchronous initialization

Discussion in 'B4J Libraries & Classes' started by Erel, Jun 22, 2014.

  1. Erel

    Erel Administrator Staff Member Licensed User

    New method: SQL.InitializeAsync - Asynchronously initializes the SQL connection. This is useful when connecting to remote databases.

    Usage example:
    Code:
    #Region  Project Attributes
       
    #AdditionalJar: mysql-connector-java-5.1.27-bin
    #End Region

    Sub Process_Globals
       
    Dim sql1 As SQL
    End Sub

    Sub AppStart (Args() As String)
       sql1.InitializeAsync(
    "sql1""com.mysql.jdbc.Driver", _
         
    "jdbc:mysql://localhost/example?characterEncoding=utf8""user""password")
       StartMessageLoop 
    'only required in a console app
    End Sub

    Sub sql1_Ready (Success As Boolean)
       
    Log(Success)
       
    If Success = False Then
         
    Log(LastException)
         
    Return
       
    End If
       
    Dim rs As ResultSet = sql1.ExecQuery("SELECT table_name FROM information_schema.tables")
       
    Do While rs.NextRow
         
    Log(rs.GetString2(0))
       
    Loop
       rs.Close
    End Sub
    Make sure to copy the library to the internal libraries folder.
     

    Attached Files:

    Roldanx, magoandroid and LucaMs like this.
  2. swissmade

    swissmade Active Member Licensed User

    Just in time for this nice Lib.
    Thanks Erel.
     
  3. jmon

    jmon Well-Known Member Licensed User

    Does Asynchronous means that the initialization and queries are on another thread? I always feel that the app freezes during the queries even in async mode.
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    ExecQueryAsync and ExecNonQueryBatch will not block the main thread. You can put a progress bar on the form. You will see that it keeps animating.

    This update adds a new InitializeAsync method that makes the initialization step asynchronous as well.
     
  5. jdiperla

    jdiperla Member Licensed User

    This library will work with MySQL databases as well?
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    Yes.
     
  7. Douglas Farias

    Douglas Farias Expert Licensed User

    @Erel
    i m using this example, but with the query on a button, when press execute the query.
    this works fine(your example), but later 1 or 2 min, i try to press the button to execute the query again and this show

    Note(it on your example, only changed the query to a button)
     
  8. Erel

    Erel Administrator Staff Member Licensed User

    Please start a new thread and post the exact code and the full error message.
     
  9. Douglas Farias

    Douglas Farias Expert Licensed User

    already fixed, this error is not on b4j its on my host(server) the mysql close connections automatic later 60s
    i made a timer on my jar, this make a query every 55s with select version() and the connection stay.

    thx
     
  10. prajinpraveen

    prajinpraveen Member Licensed User

    Please help.

    I am in a process of developing an medium-complex application. I have to decide if this can be done using B4J or PHP. i have very limited knowledge of PHP.
    1. is there anything that we cannot do with B4J which can be done by PHP alone (may be a very broad question)
    2. is it safe to connect to mySQL from B4J using JSQL or should i always have a PHP script on the remote server to handle mySQL connections

    thank you
     
  11. Erel

    Erel Administrator Staff Member Licensed User

    Please start a new thread for this question.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice