Bug? jSQL

Discussion in 'B4J Bugs & Wishlist' started by ziomorgan, Feb 9, 2015.

Similar threads

B4J Tutorial SQL Tutorial
B4J Tutorial DBUtils Example
B4J Library [B4X] DBUtils 2
B4J Code Snippet Opening MS Access databases (mdb)
B4A Tutorial [B4X] SQL with Wait For
B4J Library jSQL v1.20 - Asynchronous initialization
  1. ziomorgan

    ziomorgan Member Licensed User

    I'm using mysql database. If I use alias for a table column the resulset method "GetColumnName" give me the original column name instead of alias. it is normal ?
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    You get the value directly from the JDBC driver, so it is most probably not a bug.

    Can you post the query?
     
  3. ziomorgan

    ziomorgan Member Licensed User

    Sure,

    Code:
    DBUtils.ExecuteTableView(DBKDM, "SELECT FIELD1 AS 'ALIAS1' FROM tb1 LEFT OUTER JOIN tb2 ON (tb1.ID=tb2.ID) ORDER BY FIELD1"Null0, tv)
    this is only one but the problem is persistent for all the query (but not for SQLite)
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    Try this sub:
    Code:
    Sub GetColumnLabel(rs As ResultSet, index As Int) As String
       
    Dim jo As JavaObject = rs
       
    Return jo.RunMethodJO("getMetaData"Null).RunMethod("getColumnLabel"Array(index + 1))
    End Sub
     
    jmon and ziomorgan like this.
  5. ziomorgan

    ziomorgan Member Licensed User

    Works fine...:)

    You can include this change in the jSQL library so that the method GetColumnName return the correct value when working with SQLite and MySQL?

    I, at the time, I solved by changing DBUtils:

    Code:
    For i = 0 To cur.ColumnCount - 1
         
    Dim ColName As String
         
    If DBType = DBMYSQL Then
           ColName = GetColumnLabel(cur, i)
         
    Else
           ColName = cur.GetColumnName(i)
         
    End If
         cols.Add(ColName)
       
    Next
    thanks
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    Have you tested GetColumnLabel with SQLite? What does it return?
     
  7. ziomorgan

    ziomorgan Member Licensed User

    Work fine with SQLite too
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice