Je suis un nouveau sur b4a. Je voulais mettre en place une petite application qui interagit avec MySQL. Je suis un tutoriel mais lorsque j'essaie exécuté j'ai deux erreurs.
Connexion a MySQL. ResponseError.Reason:java.net.ConnectException:Failed to connect /192.168.50.1:17178,Response:
Error: java.net.ConnectException:Failed to connect xxx
#Region Project Attributes
#ApplicationLabel: B4A Mysql
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: False
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Private xui As XUI
Type DBResult (Tag As Object, Columns As Map, Rows As List)
Type DBCommand (Name As String, Parameters() As Object)
Private const rdcLink As String="http://192.168.50.1:17178/rdc"
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
Private LabelHead As Label
Private ListViewListTable As ListView
Private PanelHead As Panel
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Layout")
ListViewListTable.TwoLinesAndBitmap.Label.TextSize=16
ListViewListTable.TwoLinesAndBitmap.Label.TextColor=Colors.Black
ListViewListTable.TwoLinesAndBitmap.Label.Typeface=Typeface.DEFAULT_BOLD
ListViewListTable.TwoLinesAndBitmap.SecondLabel.TextSize=14
ListViewListTable.TwoLinesAndBitmap.SecondLabel.TextColor=Colors.Gray
ListViewListTable.TwoLinesAndBitmap.ItemHeight=100dip
ListViewListTable.TwoLinesAndBitmap.ItemHeight=100dip
ListViewListTable.TwoLinesAndBitmap.ImageView.Gravity=Gravity.NO_GRAVITY
ListViewListTable.TwoLinesAndBitmap.ImageView.Height=60dip
ListViewListTable.TwoLinesAndBitmap.ImageView.Width=60dip
ListViewListTable.TwoLinesAndBitmap.ImageView.Top=(ListViewListTable.TwoLinesAndBitmap.ItemHeight / 2 ) - ListViewListTable.TwoLinesAndBitmap.ImageView.Height /2
ListViewListTable.TwoLinesAndBitmap.Label.Top=(ListViewListTable.TwoLinesAndBitmap.ItemHeight /2) - ListViewListTable.TwoLinesAndBitmap.Label.Height
ListViewListTable.TwoLinesAndBitmap.Label.Left=100dip
ListViewListTable.TwoLinesAndBitmap.Label.Top=(ListViewListTable.TwoLinesAndBitmap.ItemHeight /2) - ListViewListTable.TwoLinesAndBitmap.ItemHeight
ListViewListTable.TwoLinesAndBitmap.SecondLabel.Left=100dip
SetDivider(ListViewListTable,Colors.LightGray,1dip)
GetRecord
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub CreateRequest As DBRequestManager
Dim req As DBRequestManager
req.Initialize(Me, rdcLink)
Return req
End Sub
Sub CreateCommand(Name As String, Parameters() As Object) As DBCommand
Dim cmd As DBCommand
cmd.Initialize
cmd.Name = Name
If Parameters <> Null Then cmd.Parameters = Parameters
Return cmd
End Sub
Sub GetRecord
Dim req As DBRequestManager = CreateRequest
Dim cmd As DBCommand = CreateCommand("selectAllItems", Null)
Wait For (req.ExecuteQuery(cmd, 0, Null)) JobDone(j As HttpJob)
If j.Success Then
req.HandleJobAsync(j, "req")
Wait For (req) req_Result(res As DBResult)
'work with result
req.PrintTable(res)
Log(res.Columns)
' ListViewListTable.Clear
' For Each row() As Object In res.Rows
' Dim oBitMap As Bitmap
' Dim buffer() As Byte
' buffer = row(res.Columns.Get("gambar"))
' oBitMap = req.BytesToImage(buffer)
' ListViewListTable.AddTwoLinesAndBitmap(row(1), "See more...", oBitMap)
' Next
Else
Log("ERROR: " & j.ErrorMessage)
End If
j.Release
End Sub
Sub SetDivider(lv As ListView, Color As Int, Height As Int)
Dim r As Reflector
r.Target = lv
Dim CD As ColorDrawable
CD.Initialize(Color, 0)
r.RunMethod4("setDivider", Array As Object(CD), Array As String("android.graphics.drawable.Drawable"))
r.RunMethod2("setDividerHeight", Height, "java.lang.int")
End Sub
Private Sub ListViewListTable_ItemClick (Position As Int, Value As Object)
End Sub
Private Sub ListViewListTable_ItemLongClick (Position As Int, Value As Object)
End Sub
je demande vorte aide. je rappelle que j'ai lancé xampp
voici le projet
Connexion a MySQL. ResponseError.Reason:java.net.ConnectException:Failed to connect /192.168.50.1:17178,Response:
Error: java.net.ConnectException:Failed to connect xxx
#Region Project Attributes
#ApplicationLabel: B4A Mysql
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: False
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Private xui As XUI
Type DBResult (Tag As Object, Columns As Map, Rows As List)
Type DBCommand (Name As String, Parameters() As Object)
Private const rdcLink As String="http://192.168.50.1:17178/rdc"
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
Private LabelHead As Label
Private ListViewListTable As ListView
Private PanelHead As Panel
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Layout")
ListViewListTable.TwoLinesAndBitmap.Label.TextSize=16
ListViewListTable.TwoLinesAndBitmap.Label.TextColor=Colors.Black
ListViewListTable.TwoLinesAndBitmap.Label.Typeface=Typeface.DEFAULT_BOLD
ListViewListTable.TwoLinesAndBitmap.SecondLabel.TextSize=14
ListViewListTable.TwoLinesAndBitmap.SecondLabel.TextColor=Colors.Gray
ListViewListTable.TwoLinesAndBitmap.ItemHeight=100dip
ListViewListTable.TwoLinesAndBitmap.ItemHeight=100dip
ListViewListTable.TwoLinesAndBitmap.ImageView.Gravity=Gravity.NO_GRAVITY
ListViewListTable.TwoLinesAndBitmap.ImageView.Height=60dip
ListViewListTable.TwoLinesAndBitmap.ImageView.Width=60dip
ListViewListTable.TwoLinesAndBitmap.ImageView.Top=(ListViewListTable.TwoLinesAndBitmap.ItemHeight / 2 ) - ListViewListTable.TwoLinesAndBitmap.ImageView.Height /2
ListViewListTable.TwoLinesAndBitmap.Label.Top=(ListViewListTable.TwoLinesAndBitmap.ItemHeight /2) - ListViewListTable.TwoLinesAndBitmap.Label.Height
ListViewListTable.TwoLinesAndBitmap.Label.Left=100dip
ListViewListTable.TwoLinesAndBitmap.Label.Top=(ListViewListTable.TwoLinesAndBitmap.ItemHeight /2) - ListViewListTable.TwoLinesAndBitmap.ItemHeight
ListViewListTable.TwoLinesAndBitmap.SecondLabel.Left=100dip
SetDivider(ListViewListTable,Colors.LightGray,1dip)
GetRecord
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub CreateRequest As DBRequestManager
Dim req As DBRequestManager
req.Initialize(Me, rdcLink)
Return req
End Sub
Sub CreateCommand(Name As String, Parameters() As Object) As DBCommand
Dim cmd As DBCommand
cmd.Initialize
cmd.Name = Name
If Parameters <> Null Then cmd.Parameters = Parameters
Return cmd
End Sub
Sub GetRecord
Dim req As DBRequestManager = CreateRequest
Dim cmd As DBCommand = CreateCommand("selectAllItems", Null)
Wait For (req.ExecuteQuery(cmd, 0, Null)) JobDone(j As HttpJob)
If j.Success Then
req.HandleJobAsync(j, "req")
Wait For (req) req_Result(res As DBResult)
'work with result
req.PrintTable(res)
Log(res.Columns)
' ListViewListTable.Clear
' For Each row() As Object In res.Rows
' Dim oBitMap As Bitmap
' Dim buffer() As Byte
' buffer = row(res.Columns.Get("gambar"))
' oBitMap = req.BytesToImage(buffer)
' ListViewListTable.AddTwoLinesAndBitmap(row(1), "See more...", oBitMap)
' Next
Else
Log("ERROR: " & j.ErrorMessage)
End If
j.Release
End Sub
Sub SetDivider(lv As ListView, Color As Int, Height As Int)
Dim r As Reflector
r.Target = lv
Dim CD As ColorDrawable
CD.Initialize(Color, 0)
r.RunMethod4("setDivider", Array As Object(CD), Array As String("android.graphics.drawable.Drawable"))
r.RunMethod2("setDividerHeight", Height, "java.lang.int")
End Sub
Private Sub ListViewListTable_ItemClick (Position As Int, Value As Object)
End Sub
Private Sub ListViewListTable_ItemLongClick (Position As Int, Value As Object)
End Sub
je demande vorte aide. je rappelle que j'ai lancé xampp
voici le projet
Attachments
Last edited: