Android Question jdbcsql Check unfiltered logs for JDBC errors.

sigster

Active Member
Licensed User
Longtime User
Hi

Somtime I get this error when I connect to Mysql database most of the time I get this error when I open the app for the 3 time
in KeyCodes.KEYCODE_BACK I use Return False but if I use ExitApplication it is ok

any tips how I can fix this


Check unfiltered logs for JDBC errors.
(ErrnoException) android.system.ErrnoException: connect failed: EINPROGRESS (Operation now in progress)


Regards
Sigster
 

sigster

Active Member
Licensed User
Longtime User
B4X:
STARTER

#Region  Service Attributes
    #StartAtBoot: False
    #ExcludeFromLibrary: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Public mysql As JdbcSQL
    Private driver As String = "com.mysql.jdbc.Driver"
    Private jdbcUrl As String = "jdbc:mysql://SERVER/DATABASE"
    Private Username As String = "username"
    Private Password As String = "password"
    Dim ConnectTmStart As Long
End Sub

Public Sub Connect As ResumableSub
    ConnectTmStart  =DateTime.Now
    mysql.InitializeAsync("mysql", driver, jdbcUrl, Username, Password)
    Wait For mysql_Ready (Success As Boolean)
    If Success = False Then
        Log("Check unfiltered logs for JDBC errors.")
        Log(LastException)
    Else
        Log("Connected: " &  (DateTime.Now - ConnectTmStart) & "ms")
    End If
    Return Success
    
    
End Sub

Sub CloseConnection
    mysql.Close
End Sub


Sub Service_Create
    'This is the program entry point.
    'This is a good place to load resources that are not specific to a single activity.

End Sub

Sub Service_Start (StartingIntent As Intent)
    Service.StopAutomaticForeground 'Starter service can start in the foreground state in some edge cases.
End Sub

Sub Service_TaskRemoved
    'This event will be raised when the user removes the app from the recent apps list.
End Sub

'Return true to allow the OS default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
    Return True
End Sub

Sub Service_Destroy

End Sub


--------------


Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("maincontackt")

    Wait For (CallSub(Starter,"Connect")) Complete (Success As Boolean)
    If Success Then
        Listadata
    End If
End Sub

--------------------------------------------------------------------------------------------

Sub Listadata
    
    Dim active = "Yes"
    Dim company = "-1"
    Listv_c.Clear
    Sleep(0)

    Try
        '    ProgressDialogShow2("please wait..",False)
        Dim sf As Object = Starter.mysql.ExecQueryAsync("mysql", "select f_company,mobile from m_database where f_contact Like '" & company & "%' AND status Like '" & active & "%' ORDER BY f_contact Asc", Null)       
        Wait For (sf) mysql_QueryComplete (Success As Boolean, Crsr As JdbcResultSet)
        If Success Then
            Do While Crsr.NextRow
                'Log(Crsr.GetString("f_contact"))
                Listv_c.Add(CreateListItem(Crsr.GetString("f_contact"), Listv_c.AsView.Width, 60dip), Crsr.GetString("f_contact"))
            Loop
            Crsr.Close
            '    ProgressDialogHide
            Activity.Title =  "company"
        End If
    Catch
        Success = False
        Log(LastException)
        
    End Try

End Sub

-----------------------------------------------------

Sub CreateListItem(Text As String, Width As Int, Height As Int) As Panel
    Dim p2 As Panel
    p2.Initialize("")
    p2.SetLayout(0, 0, Width, Height)
    p2.LoadLayout("maincontacktlisti")   
    MainLabel.Text = Text
    MainLabel.TextSize = 18
    But_call.Text = ""
    Dim bmp As BitmapDrawable
    bmp.Initialize(LoadBitmap(File.DirAssets, "phone.png"))
    But_call.Background = bmp
    
    If Activity.Title = "company" Then
        But_call.Visible = True
        Else
        But_call.Visible = False
    End If
    
    Return p2
End Sub

--------------------------------------------------

Sub Wait(MilliSecondi As Int)
    Dim Ti As Long
    Ti = DateTime.Now + (MilliSecondi)
  
    Do While DateTime.Now < Ti
        DoEvents
    Loop
    
  
End Sub


Sub Activity_KeyPress (KeyCode As Int) As Boolean

    If KeyCode = KeyCodes.KEYCODE_BACK Then
        'do what ever as return
        
        If Activity.Title = "Contacts" Then
            Listadata
            Return True
        Else
            Return False
'            CallSub(Starter,"CloseConnection")
'            Activity.RemoveAllViews
'            Activity.Finish
'            Wait(100)
'            ExitApplication
        End If
    End If
    
End Sub
 
Upvote 0

sigster

Active Member
Licensed User
Longtime User
full logs do you mean I remove the checkbox in filter

*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Connected: 378ms
** Activity (main) Pause, UserClosed = true **
** Activity (main) Create, isFirst = false **
** Activity (main) Resume **
Check unfiltered logs for JDBC errors.
(ErrnoException) android.system.ErrnoException: connect failed: EINPROGRESS (Operation now in progress)
 
Upvote 0

sigster

Active Member
Licensed User
Longtime User
My log

B4X:
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
a [CPS]isPredictionOnByLanguage :false, isForceOff : false, isPredictionOn : true , isOnPref : true
    at java.lang.reflect.Constructor.newInstance0(Native Method)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
e isSet :  true , isIncognitoMode :  false
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:377)
    at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1036)
    at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:338)
    at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2232)
    at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2265)
    at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2064)
    at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:790)
    at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:44)
    at java.lang.reflect.Constructor.newInstance0(Native Method)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:377)
    at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:395)
    at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:325)
    at java.sql.DriverManager.getConnection(DriverManager.java:580)
    at java.sql.DriverManager.getConnection(DriverManager.java:218)
    at anywheresoftware.b4j.objects.SQL.Initialize2(SQL.java:56)
    at anywheresoftware.b4j.objects.SQL$1.call(SQL.java:98)
    at anywheresoftware.b4j.objects.SQL$1.call(SQL.java:1)
    at anywheresoftware.b4a.BA$3.run(BA.java:461)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
    at java.lang.Thread.run(Thread.java:919)
Caused by: java.net.ConnectException: failed to connect to MYSERVER/IPADRESS (port 3306) from /IPADRESS (port 44992): connect failed: EINPROGRESS (Operation now in progress)
    at libcore.io.IoBridge.connect(IoBridge.java:143)
    at java.net.PlainSocketImpl.socketConnect(PlainSocketImpl.java:142)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:390)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:230)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:212)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:436)
    at java.net.Socket.connect(Socket.java:621)
    at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:213)
    at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:297)
    ... 21 more
Caused by: android.system.ErrnoException: connect failed: EINPROGRESS (Operation now in progress)
    at libcore.io.Linux.connect(Native Method)
    at libcore.io.ForwardingOs.connect(ForwardingOs.java:95)
    at libcore.io.BlockGuardOs.connect(BlockGuardOs.java:136)
    at libcore.io.ForwardingOs.connect(ForwardingOs.java:95)
    at libcore.io.IoBridge.connectErrno(IoBridge.java:157)
    at libcore.io.IoBridge.connect(IoBridge.java:135)
    ... 29 more
 
Upvote 0
Top