Android Question jRDC2 parameter error

Csaba Balogh

Member
Licensed User
Hi There!

I am facing a problem with jRDC2. I can connect successfully, I can also get back data from DB when there are no parameters in the query, but when I try to send a WHERE clause from the app I get parameter error (attached).
B4X:
ResponseError. Reason: java.net.SocketTimeoutException: timeout, Response:
ERROR: java.net.SocketTimeoutException: timeout
ResponseError. Reason: java.net.SocketTimeoutException: connect timed out, Response:
ERROR: java.net.SocketTimeoutException: connect timed out
ResponseError. Reason: java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0)., Response: <html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>Error 500 java.sql.SQLException: Parameter index out of range (1 &gt; number of parameters, which is 0).</title>
</head>
<body><h2>HTTP ERROR 500</h2>
<p>Problem accessing /rdc. Reason:
<pre>    java.sql.SQLException: Parameter index out of range (1 &gt; number of parameters, which is 0).</pre></p><hr><a href="http://eclipse.org/jetty">Powered by Jetty:// 9.4.z-SNAPSHOT</a><hr/>
</body>
</html>
ERROR: <html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>Error 500 java.sql.SQLException: Parameter index out of range (1 &gt; number of parameters, which is 0).</title>
</head>
<body><h2>HTTP ERROR 500</h2>
<p>Problem accessing /rdc. Reason:
<pre>    java.sql.SQLException: Parameter index out of range (1 &gt; number of parameters, which is 0).</pre></p><hr><a href="http://eclipse.org/jetty">Powered by Jetty:// 9.4.z-SNAPSHOT</a><hr/>
</body>
</html>
ResponseError. Reason: java.net.SocketTimeoutException: connect timed out, Response:
ERROR: java.net.SocketTimeoutException: connect timed out
The sub I use:

B4X:
Sub GetLogin(devid As Int)
    Dim su As StringUtils
    Dim req As DBRequestManager = CreateRequest
    Dim cmd As DBCommand = CreateCommand("login", Array(devid))
    Wait For (req.ExecuteQuery(cmd, 0, Null)) JobDone(j As HttpJob)
    If j.Success Then
        req.HandleJobAsync(j, "req")
        Wait For (req) req_Result(res As DBResult)
        'work with result
        Dim row() As Object =res.Rows.Get(0)
        Dim dbpassw As String=row(0)
        If txtPassw.text=DecryptText(su.DecodeBase64(dbpassw), "xxxxx") Then
            Activity.Finish
            StartActivity(Main)
        Else
            Msgbox("Wrong id or password! Please try again.", "Error")
        End If
    Else
        Log("ERROR: " & j.ErrorMessage)
    End If
    j.Release
End Sub
And finally the config.properties:

B4X:
#Lines starting with '#' are comments.
#Backslash character at the end of line means that the command continues in the next line.

#DATABASE CONFIGURATION
DriverClass=com.mysql.jdbc.Driver
JdbcUrl=jdbc:mysql://xxxx.xxxx.xx?characterEncoding=utf8
User=xxxx
Password=xxxx
#Java server port
ServerPort=17178

#example of MS SQL Server configuration:
#DriverClass=net.sourceforge.jtds.jdbc.Driver
#JdbcUrl=jdbc:jtds:sqlserver://<server address>/<database>

#example of postegres configuration:
#JdbcUrl=jdbc:postgresql://localhost/test
#DriverClass=org.postgresql.Driver

#SQL COMMANDS
#sql.create_table=CREATE TABLE IF NOT EXISTS animals (\
#     id INTEGER PRIMARY KEY AUTO_INCREMENT,\
#     name CHAR(30) NOT NULL,\
#     image BLOB)
#sql.insert_animal=INSERT INTO animals VALUES (null, ?,?)
#sql.select_animal=SELECT name, image, id FROM animals WHERE id = ?;
#sql.create_table=CREATE TABLE article (col1 numeric(10,4) ,col2 text);
#sql.select=select * from article
#sql.insert=INSERT INTO article VALUES(?, ?)

sql.get_emails=SELECT clientemail FROM clients
sql.login=SELECT devicepassw FROM device WHERE device_id = ?
Could you please help me out?
Thanks a lot!
 
Top