Spanish jrdc2 con B4J

Ricardo Gonzalez Gaete

Member
Licensed User
Longtime User
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Type DBResult (Tag As Object, Columns As Map, Rows As List)
Type DBCommand (Name As String, Parameters() As Object)
Private rdcLink As String = "http://192.168.0.2:10199/test"
End Sub
 

Ricardo Gonzalez Gaete

Member
Licensed User
Longtime User
java.net.SocketTimeoutExcepcyion.connect timed Out
[ CODE ]
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Type DBResult (Tag As Object, Columns As Map, Rows As List)
Type DBCommand (Name As String, Parameters() As Object)
Private rdcLink As String = "http://192.168.0.2:10199/rdc"
End Sub
[/CODE ]
 

Ricardo Gonzalez Gaete

Member
Licensed User
Longtime User
B4X:
java.net.SocketTimeoutExcepcyion.connect timed Out

Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Type DBResult (Tag As Object, Columns As Map, Rows As List)
Type DBCommand (Name As String, Parameters() As Object)
Private rdcLink As String = "http://192.168.0.2:10199/rdc"
End Sub

ahí si el formato
 

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
lo siguiente que hay que descartar es que el JRDC no este mandandote excepciones, puedes ver el en el log si no tienes errores?
 

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
No, me refiero a las excepciones en JRDC2 de b4j por alguna razon no te esta enviendo la respuesta, seguramente en tus logs va a aparecer.
 

Ricardo Gonzalez Gaete

Member
Licensed User
Longtime User
Waiting for debugger to connect...
Program started.
2017-11-27 16:00:47.206:INFO::main: Logging initialized @598ms to org.eclipse.jetty.util.log.StdErrLog
nov 27, 2017 4:00:47 PM com.mchange.v2.log.MLog
INFORMACIÓN: MLog clients using java 1.4+ standard logging.
nov 27, 2017 4:00:47 PM com.mchange.v2.c3p0.C3P0Registry
INFORMACIÓN: Initializing c3p0-0.9.5.2 [built 08-December-2015 22:06:04 -0800; debug? true; trace: 10]
2017-11-27 16:00:47.538:INFOejs.Server:main: jetty-9.4.z-SNAPSHOT
2017-11-27 16:00:47.571:INFOejs.session:main: DefaultSessionIdManager workerName=node0
2017-11-27 16:00:47.571:INFOejs.session:main: No SessionScavenger set, using defaults
2017-11-27 16:00:47.573:INFOejs.session:main: Scavenging every 600000ms
2017-11-27 16:00:47.577:INFOejsh.ContextHandler:main: Started o.e.j.s.ServletContextHandler@4d95d2a2{/,file:///C:/Users/Kreasoft/Desktop/ServidorJRDC2/JRDC2/Objects/www,AVAILABLE}
2017-11-27 16:00:47.587:INFOejs.AbstractNCSARequestLog:main: Opened C:\Users\Kreasoft\Desktop\ServidorJRDC2\JRDC2\Objects\logs\b4j-2017_11_27.request.log
2017-11-27 16:00:47.599:INFOejs.AbstractConnector:main: Started ServerConnector@467aecef{HTTP/1.1,[http/1.1]}{0.0.0.0:10199}
2017-11-27 16:00:47.600:INFOejs.Server:main: Started @992ms
Emulated network latency: 100ms
jRDC is running (version = 2.1)
nov 27, 2017 5:18:44 PM com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource
INFORMACIÓN: Initializing c3p0 pool... com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 3, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 20000, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, contextClassLoaderSource -> caller, dataSourceName -> 1hge0w29r1ypnnlz1knbctv|532760d8, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> com.mysql.jdbc.Driver, extensions -> {}, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, forceSynchronousCheckins -> false, forceUseNamedDriverClass -> false, identityToken -> 1hge0w29r1ypnnlz1knbctv|532760d8, idleConnectionTestPeriod -> 600, initialPoolSize -> 3, jdbcUrl -> jdbc:mysql://localhost/test?characterEncoding=utf8, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 1800, ma...
Unknown method:
Command: , took: 3ms, client=127.0.0.1







 

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
lo bueno es que si hay errores por lo que sabemos que tu dispositivo y tu servidor si estan comunicando.

el problema es que no estas pasando un comando correcto al servidor y por eso no hace nada.

por lo que yo creo que estas corriendo el ejemplo que te di sin haberlo modificado o sin modificarlo adecuadamente.

Puedes postear el codigo del cliente, completo y que query estas intendo hacer y llamar, tambien apoyame con tu config.properties de JRDC2 para ver la parte de las queries.
 

Ricardo Gonzalez Gaete

Member
Licensed User
Longtime User
Codigo Cliente

B4X:
#Region  Project Attributes 
 #ApplicationLabel: B4A Example
 #VersionCode: 1
 #VersionName: 
 'SupportedOrientations possible values: unspecified, landscape or portrait.
 #SupportedOrientations: unspecified
 #CanInstallToExternalStorage: False
#End Region
#Region  Activity Attributes 
 #FullScreen: False
 #IncludeTitle: 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.
 Type DBResult (Tag As Object, Columns As Map, Rows As List)
 Type DBCommand (Name As String, Parameters() As Object)
 Private rdcLink As String = "http://192.168.0.2:10199/rdc"
End Sub
Sub Globals
 'These global variables will be redeclared each time the activity is created.
 'These variables can only be accessed from this module.
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("Layout1")
  testconnection

End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub testconnection
 Wait For (GetRecord(25)) Complete (result As DBResult)
 If result = Null Then
 Msgbox("SIN CONEXION","ERR")
 Return
 End If
 Log(result.Rows.Size)
 
 If result.Rows.Size > 0 Then
 Dim r() As String = result.Rows.Get(0)
 Log(r(0))
 End If
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
 cmd.Parameters = Parameters
 Return cmd
End Sub
Sub GetRecord (id As Int) As ResumableSub
 Dim req As DBRequestManager = CreateRequest
 Dim cmd As DBCommand = CreateCommand("create_table", Null)
 'req.ExeucteQuery returns a HttpJob. The returned HttpJob is used as the sender filter.
 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)
 Return res
 Else
 Msgbox(j.ErrorMessage,"eRR") ' Log("ERROR: " & j.ErrorMessage)
 End If
 j.Release
 Dim res As DBResult = Null
 Return res
End Sub
Sub InsertRecord (Name As String)
 Dim cmd As DBCommand = CreateCommand("insert_animal", Array(Name, Null))
 Dim j As HttpJob = CreateRequest.ExecuteBatch(Array(cmd), Null)
 Wait For(j) JobDone(j As HttpJob)
 If j.Success Then
 Log("Inserted successfully!")
 End If
 j.Release
End Sub


Archivo config
B4X:
#Lines starting with '#' are comments.
#Backslash character at the end of line means that the command continues in the next line.
#DATABASE CONFIGURATION
DriverClass=com.mysql.jdbc.Driver
JdbcUrl=jdbc:mysql://localhost/test?characterEncoding=utf8
User=root
Password=rgg1968
#Java server port
ServerPort=10199
#example of MS SQL Server configuration:
#DriverClass=net.sourceforge.jtds.jdbc.Driver
#JdbcUrl=jdbc:jtds:sqlserver://<server address>/<database>
#example of postegres configuration:
#JdbcUrl=jdbc:postgresql://localhost/test
#DriverClass=org.postgresql.Driver
#SQL COMMANDS
#sql.create_table=CREATE TABLE IF NOT EXISTS animals (\
#  id INTEGER PRIMARY KEY AUTO_INCREMENT,\
#  name CHAR(30) NOT NULL,\
#  image BLOB)
#sql.insert_animal=INSERT INTO animals VALUES (null, ?,?)
#sql.select_animal=SELECT name, image, id FROM animals
sql.create_table=CREATE TABLE article (col1 numeric(10,4) ,col2\ text);
sql.select=select * from article
sql.insert=INSERT INTO article VALUES(?, ?)


Ahí vamos....
 

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
creo que el problema esta aqui:

B4X:
Sub GetRecord (id As Int) As ResumableSub
 Dim req As DBRequestManager = CreateRequest
 Dim cmd As DBCommand = CreateCommand("create_table", Null)
 'req.ExeucteQuery returns a HttpJob. The returned HttpJob is used as the sender filter.
 Wait For (req.ExecuteQuery(cmd, 0, Null)) JobDone(j As HttpJob)

create table es un comando que afecta la base (nonquery) y lo estamos mandando a llamar como un query. En tu config podrias poner un Select real a alguna tabla que tengas en esa base?
 

Ricardo Gonzalez Gaete

Member
Licensed User
Longtime User
B4X:
En Config
JdbcUrl=jdbc:mysql://localhost/kreagestion?characterEncoding=utf8

Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Type DBResult (Tag As Object, Columns As Map, Rows As List)
Type DBCommand (Name As String, Parameters() As Object)

que se pone aquí Según Config 
Private rdcLink As String = "http://192.168.0.2:10199/rdc"
0
Private rdcLink As String = "http://192.168.0.2:10199/kreagestion"

End Sub

Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
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("Layout1")
testconnection

End Sub
Sub Activity_Resume
End Sub
[/CODE ]

sigo con timeout
 

Ricardo Gonzalez Gaete

Member
Licensed User
Longtime User
B4X:
#Lines starting with '#' are comments.
#Backslash character at the end of line means that the command continues in the next line.
#DATABASE CONFIGURATION
DriverClass=com.mysql.jdbc.Driver
JdbcUrl=jdbc:mysql://localhost/kreagestion?characterEncoding=utf8
User=krea
Password=rgg1968
#Java server port
ServerPort=10199
#example of MS SQL Server configuration:
#DriverClass=net.sourceforge.jtds.jdbc.Driver
#JdbcUrl=jdbc:jtds:sqlserver://<server address>/<database>
#example of postegres configuration:
#JdbcUrl=jdbc:postgresql://localhost/test
#DriverClass=org.postgresql.Driver
#SQL COMMANDS
#sql.create_table=CREATE TABLE IF NOT EXISTS animals (\
#  id INTEGER PRIMARY KEY AUTO_INCREMENT,\
#  name CHAR(30) NOT NULL,\
#  image BLOB)
#sql.insert_animal=INSERT INTO animals VALUES (null, ?,?)
#sql.select_animal=SELECT name, image, id FROM animals
#sql.create_table=CREATE TABLE article (col1 numeric(10,4) ,col2#\ text)
#sql.insert=INSERT INTO article VALUES(?, ?)

Esta es una tabla verdadera de kreagestion

sql.select_vend=select * from vendedores


ASI QUEDO EL CONFIG:
AFECTA en la query Mayúsculas o da lo mismo



B4X:
Código Cliente


#Region  Project Attributes
#ApplicationLabel: B4A Example
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region  Activity Attributes
#FullScreen: False
#IncludeTitle: 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.
Type DBResult (Tag As Object, Columns As Map, Rows As List)
Type DBCommand (Name As String, Parameters() As Object)
Private rdcLink As String = "http://192.168.0.2:10199/rdc"
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
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("Layout1")
  testconnection
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub testconnection
Wait For (GetRecord(25)) Complete (result As DBResult)
If result = Null Then
Msgbox("SIN CONEXION","ERR")
Return
End If
Log(result.Rows.Size)

If result.Rows.Size > 0 Then
Dim r() As String = result.Rows.Get(0)
Log(r(0))
End If
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
cmd.Parameters = Parameters
Return cmd
End Sub
Sub GetRecord (id As Int) As ResumableSub
Dim req As DBRequestManager = CreateRequest
Dim cmd As DBCommand = CreateCommand("select_vend", Null)
'req.ExeucteQuery returns a HttpJob. The returned HttpJob is used as the sender filter.
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)
Return res
Else
Msgbox(j.ErrorMessage,"eRR") ' Log("ERROR: " & j.ErrorMessage)
End If
j.Release
Dim res As DBResult = Null
Return res
End Sub
Sub InsertRecord (Name As String)
Dim cmd As DBCommand = CreateCommand("insert_animal", Array(Name, Null))
Dim j As HttpJob = CreateRequest.ExecuteBatch(Array(cmd), Null)
Wait For(j) JobDone(j As HttpJob)
If j.Success Then
Log("Inserted successfully!")
End If
j.Release
End Sub


B4X:
  CODIGO SERVIDOR

Sub AppStart (Args() As String)
srvr.Initialize("")
rdcConnector1.Initialize
srvr.Port = rdcConnector1.serverPort
srvr.AddHandler("/kreagestion", "TestHandler", False)
srvr.AddHandler("/rdc", "RDCHandler", False)
srvr.Start
Log($"jRDC is running (version = $1.2{VERSION})"$)
StartMessageLoop
End Sub
 

Ricardo Gonzalez Gaete

Member
Licensed User
Longtime User
Lo Otro Amigo, esto paso cuando cambie el nombre del paquete

Al Compliar sale

B4A Versión: 7.30
Parseando código. (0.00s)
Compilando código (0.10s)
Compilado código de diseños (0.03s)
Organizando librerías. (2.81s)
Generando el fichero R. Error
AndroidManifest.xml:16: error: Error parsing XML: not well-formed (invalid token)
 

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
Todo parece en orden.

te sigue apareciendo timeout?

si si, vamos a hacer lo siguiente, entra a la clase RDCHandler y ubica esta linea
Dim rs As ResultSet = con.ExecQuery2(Main.rdcConnector1.GetCommand(cmd.Name), cmd.Parameters)

y ponle un break point y vamos a ver si hasta ahi todo va bien.

---------

con el paquete no estoy seguro, tendrias que mandarme el proyecto, si quieres crea otro basico donde puedas replciar el error
 

Ricardo Gonzalez Gaete

Member
Licensed User
Longtime User
Lo Otro Amigo, esto paso cuando cambie el nombre del paquete

Al Compliar sale

B4A Versión: 7.30
Parseando código. (0.00s)
Compilando código (0.10s)
Compilado código de diseños (0.03s)
Organizando librerías. (2.81s)
Generando el fichero R. Error
AndroidManifest.xml:16: error: Error parsing XML: not well-formed (invalid token)
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…