B4J Question [SOLVED] TimeoutException again

incendio

Well-Known Member
Licensed User
Longtime User
Hi guys,

I got TimeoutException error again!
The error message is
(TimeoutException) com.mchange.v2.resourcepool.TimeoutException: A client timed out while waiting to acquire a resource from com.mchange.v2.resourcepool.BasicResourcePool@24a35978 -- timeout at awaitAvailable()

I have follow this thread :

to increase connection pool with this code
B4X:
Sub Process_Globals
   Public srvr As Server
   Public rdcConnector1 As RDCConnector
   Public PathToConfigFile As String
   Type DBCommand (Name As String, Parameters() As Object)
   Type DBResult (Tag As Object, Columns As Map, Rows As List)
   Private dbpool As ConnectionPool
   Private Tm As Timer
End Sub

Sub AppStart (Args() As String)
    srvr.Initialize("")
    If PathToConfigFile <> "" Then srvr.LogsFileFolder = PathToConfigFile
    rdcConnector1.Initialize
    
    srvr.Port = rdcConnector1.serverPort
    srvr.AddHandler("/rdc", "RDCHandler", False)
    srvr.Start

    dbpool.Initialize( "org.firebirdsql.jdbc.FBDriver",....)
    Dim jo As JavaObject = dbpool
   
    jo.RunMethod("setMaxPoolSize", Array As Object(100))
    Tm.Initialize("TM",10000)
    Tm.Enabled = True
    StartMessageLoop    
End Sub

But It didn't work. I doubt it was because connection pool because the error raised a few seconds after app started.

Here are the codes that raised that error
B4X:
Sub TM_Tick
    Private Qry1,Qry2,Qry3 As SQL
    Private RS1,RS2,RS3 As ResultSet
    Private RowsExist As Boolean
   
    Tm.Enabled = False
   
    Try
        Qry1     = dbpool.GetConnection      
        RS1       = Qry1.ExecQuery("SELECT * from table1 rows 1")
        RowsExist= False
        Do While RS1.NextRow
            'do some proses'
            RowsExist= True
        Loop
       
        If RowsExist Then
            'do some proses'
        End If
   
        Qry2     = dbpool.GetConnection      
        RS2       = Qry2.ExecQuery("SELECT * from table2 rows 1")
        RowsExist= False
        Do While RS2.NextRow
            'do some proses'
            RowsExist= True
        Loop
               
        If RowsExist Then
            'do some proses'
        End If
       
        Qry3     = dbpool.GetConnection
        RS3         = Qry3.ExecQuery("SELECT * from table3 rows 1")
        RowsExist= False
        Do While RS3.NextRow
            'do some proses'
            RowsExist= True
        Loop
       
        If RowsExist Then
            'do some proses'
        End If

    Catch
        File.WriteString(File.DirApp,"Error.err",LastException)
    End Try

    RS1.Close
    Qry1.Close
    RS2.Close
    Qry2.Close
    RS3.Close
    Qry3.Close

    Tm.Enabled = True
End Sub

Here are my settings
  • B4J ver 7.32
  • JavaObject ver 2.06
  • jNet ver 1.80
  • jRandomAccesFile ver 2.32
  • jServer ver 3.00
  • jSQL ver 1.60
The App runs on Ubunntu server ver 16.
 

incendio

Well-Known Member
Licensed User
Longtime User
I don't need new features in newer version of B4J.

Username and password are OK.

Database server, runs ok.

Will try to update B4J, see if this solve the problem.

Btw, this is not the only app that runs on that server.

There's another app runs on that server, build with the same B4J version but don't have a problem like this.
 
Upvote 0

incendio

Well-Known Member
Licensed User
Longtime User
Hi,

Found the problem although still use old B4J.

The problem is in this code
B4X:
dbpool.Initialize("org.firebirdsql.jdbc.FBDriver","jdbc:firebirdsql://localhost:/dba?charSet=utf-8","abc","123")
The JdbcURL in that parameter point to not exist database, while JdbcURL in properties file point to a valid database.

Although an error raised, app from B4A can still insert/edit or retrieve correct data from the server without any issues.
 
Upvote 0
Top