B4J Question jrdc2 server: How to log sql string

Discussion in 'B4J Questions' started by yfleury, Nov 10, 2019.

  1. yfleury

    yfleury Active Member Licensed User

    I have in config.properties a sql string like
    Code:
    sql.select_mytable= select * from table where item1 = ? and item2 = ? order by item3
    I want to log the sql string with parameters on jrdc2 server like
    Code:
    select * from table where item1 = 33 and item2 = "old" order by item3
    Is it possible?
     
  2. OliverA

    OliverA Expert Licensed User

  3. yfleury

    yfleury Active Member Licensed User

    I run jrdc 2 server in debug mode I just want to show parameters on log tab
     
  4. OliverA

    OliverA Expert Licensed User

    Note: Untested
    You could add the following code to both ExecuteQuery2 and ExecuteBatch2 of the RDCHandler class module of the jRDC2 source code:
    Code:
    #If Debug
       Dim sb As StringBuilder
       sb.Initialize
       sb.Append($"Query: ${Main.rdcConnector1.GetCommand(cmd.Name)}"$)
       Dim first As Boolean = True
       For Each parameter As Object In cmd.Parameters
           If first Then
               sb.Append($" Parameter(s): ${parameter}"$)
               first = False
           Else
               sb.Append($", ${parameter}"$)
           End If
       Next
       Log(sb.ToString)
    #End If
    In ExecuteQuery2, place it after
    Code:
    Dim cmd As DBCommand = m.Get("command")
    In ExecuteBatch2, place it in the loop that execute the commands, after
    Code:
    For Each cmd As DBCommand In commands
     
  5. yfleury

    yfleury Active Member Licensed User

    You are the king Thanks
    I test your code and it work well
     
  6. José J. Aguilar

    José J. Aguilar Well-Known Member Licensed User

    OliverA is the master of jRDC2!! He knows jRDC2 perfectly and he's always ready to help
     
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