'Non-UI application (console / server application)
#Region Project Attributes
#MergeLibraries: True
#AdditionalJar: mysql-connector-java-5.0.8-bin.jar
#End Region
Sub Process_Globals
End Sub
Sub AppStart (Args() As String) As String
Try
Dim lstResp As List
lstResp.Initialize
Dim jSQL As SQL
jSQL.Initialize2("com.mysql.jdbc.Driver", "jdbc:mysql://XXXXXX:3306/YYYYY?characterEncoding=utf8", "ZZZZZZ","TTTTTTT")
Dim rs As ResultSet=jSQL.ExecQuery("SELECT * FROM eventos WHERE valido=1 ORDER BY fecha")
Do While rs.NextRow
Dim newEvento As Map
newEvento.Initialize
newEvento.Put("IdEvento",rs.GetInt("idevento"))
newEvento.Put("Nombre",rs.GetString("nombre"))
newEvento.Put("Lugar",rs.GetString("lugar"))
newEvento.Put("Fecha",rs.GetString("fecha"))
newEvento.Put("Hora",rs.GetString("hora"))
newEvento.Put("Tipo",rs.GetInt("tipo"))
lstResp.Add(newEvento)
Loop
rs.Close
jSQL.Close
Dim mapJson As Map
mapJson.Initialize
mapJson.Put("statusCode",200)
mapJson.Put("body",lstResp)
Dim MyJG As JSONGenerator
MyJG.Initialize(mapJson)
Return MyJG.ToString
Catch
rs.Close
jSQL.Close
Dim mapJson As Map
mapJson.Initialize
mapJson.Put("statusCode",200)
mapJson.Put("body","Se produjo un error: " & LastException)
Dim MyJG As JSONGenerator
MyJG.Initialize(mapJson)
Return MyJG.ToString
End Try
End Sub