You cant catch them... Write queries which dont raise an exception.how capture the sqlException
You cant catch them... Write queries which dont raise an exception.how capture the sqlException
You cant catch them... Write queries which dont raise an exception.
Sub MySQL_ListTables(tables As List, ms As Long)
Log("MySQL_ListTables("&ms&"ms)")
For i=0 To tables.Size-1
Log("Table "&tables.Get(i))
Next
End Sub
java.lang.ClassCastException: java.lang.String cannot be cast to anywheresoftware.b4a.objects.collections.Map$MyMap
Sub ArmoPantallaTablas
Telefono.SetScreenOrientation(1)
g.Initialize(Me,"g")
g.InitializeTable(2,0,False)
g.AddToActivity(Activity, 0, 54dip, 100%x, 80%y)
g.SetHeader(Array As String("Table Name", "Rows"))
g.SetColumnsWidths(Array As Int(80%x, 20%x))
' Leo los registros
Indice=1
Maximo=0
BotonQuery.Enabled=False
ProgressDialogShow("Reading Tables")
Starter.Dbn.QueryASync2("SELECT TABLE_NAME, TABLE_ROWS, TABLE_SCHEMA FROM TABLES WHERE TABLE_TYPE='BASE TABLE' ORDER BY TABLE_NAME","ListaTablas")
BotonStructures.Enabled=False
Activity.AddMenuItem("Jump Next 15", "Jump1")
Activity.AddMenuItem("Jump To 0", "Jump2")
End Sub
Sub ListaTablas_QueryResult2(data As List, meta As Map)
Dim m As Map
Maximo=Maximo+1
Log("MySQL_QueryResult("&meta&")")
For i=0 To data.Size-1
m=data.Get(i)
If i = 0 Then Starter.BaseSeleccionada=m.Get("TABLE_SCHEMA")
g.AddRow(Array As String(m.Get("TABLE_NAME"),m.Get("TABLE_ROWS")))
Next
ProgressDialogHide
BotonQuery.Enabled=True
Activity.Title=" Tables of " & Starter.BaseSeleccionada
End Sub
g.AddRow(Array As String(m.Get("TABLE_NAME"),m.Get("TABLE_ROWS")))
QueryASync2
/**
* Query the Database. When the Method finishes the event QueryResult2
* will be raised
* QueryResult gets two values. A "List of Strings" for the results. Each
* Item in the List contains a String holding the Values from on Resultrow
* in the format "["+field1+","+field2+"]"
*
* The Second value is a Map containing some informations:
* ColumnCount, RecordCount and time elapsed in ms for the query
*Example:<code>
*db.queryasync2("select * from members LIMIT 0,1 ;")</code>
*/
You should use QueryAsync if you want to get a list of maps.
Starter.Dbn.Initialize("MySQL",Starter.MySQL_Server&":"&Starter.MySQL_Port,"information_schema",Starter.MySQL_User,Starter.MySQL_Password,True,True)
Starter.Dbn.QueryASync("SELECT DISTINCT(TABLE_SCHEMA) AS BASE, Count(DISTINCT(TABLE_SCHEMA)) as Registros FROM TABLES WHERE TABLE_SCHEMA<>'information_schema'","VerTablas")
Sub MySQL_QueryResult(data As List, meta As Map)
Dim m As Map
CantidadBases=0
For i = 0 To data.Size-1
CantidadBases=CantidadBases+1
m=data.Get(i)
Starter.ListadeBases.Add(m.Get("TABLE_SCHEMA"))
Next
If data.size=1 Then StartActivity(ListaTablas)
If data.Size>1 Then StartActivity(Databases)
End Sub
For i = 0 To data.Size-1
add the port to the host if you need a different on than 3306 (somedomain.tld:3333)Why the PORT parameter is not included in the Connection Parameters ?
The method to get a tablelist isbut not ReadTables_QueryResult
db.ListTablesAsync()
Sub MySQL_ListTables(tables As List, ms As Long)
Log("MySQL_ListTables("&ms&"ms)")
For i=0 To tables.Size-1
Log("Table "&tables.Get(i))
Next
End Sub
The method to get a tablelist is
and it results in raisingB4X:db.ListTablesAsync()
B4X:Sub MySQL_ListTables(tables As List, ms As Long) Log("MySQL_ListTables("&ms&"ms)") For i=0 To tables.Size-1 Log("Table "&tables.Get(i)) Next End Sub
If data.Get("COLLATION_NAME")<>Null Then
Cola=data.Get("COLLATION_NAME")
Else
Cola=""
End If
** Activity (main) Pause, UserClosed = false **
** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
MySQL Database not connected!
Sub NOT FOUND: 'vertablas_status
Connected to Database
** Activity (main) Pause, UserClosed = false **
** Activity (listatablas) Create, isFirst = true **
** Activity (listatablas) Resume **
** Activity (listatablas) Pause, UserClosed = false **
** Activity (estructuras) Create, isFirst = true **
** Activity (estructuras) Resume **
An error occurred:
(Line: 72) If data.Get("COLUMN_DEFAULT")<>Null Then
java.lang.NumberFormatException: For input string: "COLUMN_DEFAULT"
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **