B4J Question jRDC2 config.properties

Alexander Stolte

Expert
Licensed User
Longtime User
Hello community, i have a problem, because i dont understand what i insert into 2 columns.

I have looked every tutorial, about it here, in the forum. The most user are using MySql, but i have a MS Sql Database. So, now to my Question.

In the file "config.properties" exist the column "DriverClass" and JdbcUrl"

DriverClass: I should specify the location where the driver is located? So it would look like this? : "C:\Program Files\Microsoft JDBC Driver 6.0 for SQL Server\sqljdbc_6.0\deu\jre8\sqljdbc42.jar"

JdbcUrl: and here the path where the jRDC.jar file located? Looks like: C:\Users\Administrator\Desktop\jRDC.jar

thanks for help. :)

My first post without translator jay :cool:
 

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
Awesome!!

I have a another question.

you can create any number of sql statements in in the config.properties file, just name then accordingly.

For example:

B4X:
sql.SelectAllFromTable_1=select column_1 from table_1

Then in your JRDC client app, you will make the request like this:

B4X:
    reqManager.ExecuteQuery(cmd, 0, "SelectAllFromTable_1")
 
Upvote 0

Alexander Stolte

Expert
Licensed User
Longtime User
The log said:

B4X:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>

<title>404 - File or directory not found.</title>

<style type="text/css">

<!--

body{margin:0;font-size:.7em;font-family:Verdana, Arial, Helvetica, sans-serif;background:#EEEEEE;}

fieldset{padding:0 15px 10px 15px;}

h1{font-size:2.4em;margin:0;color:#FFF;}

h2{font-size:1.7em;margin:0;color:#CC0000;}

h3{font-size:1.2em;margin:10px 0 0 0;color:#000000;}

#header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:"trebuchet MS", Verdana, sans-serif;color:#FFF;

background-color:#555555;}

#content{margin:0 0 0 2%;position:relative;}

.content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;position:relative;}

-->

</style>

</head>

<body>

<div id="header"><h1>Server Error</h1></div>

<div id="content">

<div class="content-container"><fieldset>

  <h2>404 - File or directory not found.</h2>

  <h3>The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.</h3>

</fieldset></div>

</div>

</body>

</html>

Error: Not Found

i use the b4a code from here

is that right? :
B4X:
If FirstTime Then
        reqManager.Initialize(Me, "http://myipfromserver/rdc")
    End If
 
Upvote 0

Alexander Stolte

Expert
Licensed User
Longtime User
sry for b4a code:

B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Dim reqManager As DBRequestManager
    Type DBResult (Tag As Object, Columns As Map, Rows As List)
    Type DBCommand (Name As String, Parameters() As Object)
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")

    If FirstTime Then
        reqManager.Initialize(Me, "http://myserverip/rdc")
    End If
   
    Activity.LoadLayout("frm_main")
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub




Sub btn_select_Click
    Dim cmd As DBCommand
    cmd.Initialize
    cmd.Name = "select_too"
    reqManager.ExecuteQuery(cmd, 0, Null) 'NULL
End Sub

Sub JobDone(Job As HttpJob)
    If Job.Success = False Then
        Log("Error: " & Job.ErrorMessage)
    Else
        If Job.JobName = "DBRequest" Then
            reqManager.HandleJobAsync(Job, "ReqManager")
        End If
    End If
    Job.Release
End Sub

Sub ReqManager_Result(result As DBResult)
    ToastMessageShow(reqManager.PrintTable(result), True)
End Sub

The data has been adapted to my database.
 
Upvote 0

Alexander Stolte

Expert
Licensed User
Longtime User
Now it works! :)
port number

the port number is the port number from Java server :)

the log said:
B4X:
** Service (httputils2service) Create **
** Service (httputils2service) Start **
Class not found: b4j.example.main$_dbresult, trying: com.database.main$_dbresult
Tag: null, Columns: 1, Rows: 3
erster   
Test1    
Test2   
Test3
 
Upvote 0

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
awesome!

B4X:
Class not found: b4j.example.main$_dbresult, trying: com.database.main$_dbresult

This is pretty much normal, nothing to worry about.

B4X:
erster 
Test1 
Test2 
Test3

and this are your logs, so everything is fine now!
 
Upvote 0

Alexander Stolte

Expert
Licensed User
Longtime User
a last question:

B4X:
Sub ReqManager_Result(result As DBResult)
    ToastMessageShow(reqManager.PrintTable(result), True)
    result.Tag =  reqManager.PrintTable(result)
    lbl_text.Text = result
   
End Sub

How can i show the result on my label? not only on the log?
 
Upvote 0

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
For example.

Your query returned 1 column and 3 rows

if you want to assign any of the 3 possible results it will be like this:

B4X:
'0 for first row
'1 for second row and so forth
dim row() as string = result.rows.get(0)

'First row and first column 
lbl_text.text = row(0)
 
Upvote 0
Top