Android Question Insert JRDC2 with Postgresql

Ederson Kerber

Member
Licensed User
Hi,

We are developing an app with Postgresql with JRDC2. Following the https://www.b4x.com/android/forum/t...-rdc-remote-database-connector.61801/#content post we can connect to the database and execute queries (selects).

But when we run Insert, Update or Delete we get an error:

ResponseError. Reason: org.postgresql.util.PSQLException: The column index is out of range: 1, number of columns: 0., Response: <html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>Error 500 org.postgresql.util.PSQLException: The column index is out of range: 1, number of columns: 0.</title>
</head>
<body><h2>HTTP ERROR 500</h2>
<p>Problem accessing /rdc. Reason:
<pre> org.postgresql.util.PSQLException: The column index is out of range: 1, number of columns: 0.</pre></p><hr><a href="http://eclipse.org/jetty">Powered by Jetty:// 9.4.z-SNAPSHOT</a><hr/>
</body>
</html>
** Activity (main) Pause, UserClosed = false **


By executing the Insert command directly on the database, no error occurs. Ex:
insert into pessoas values ('maria', 30)


- Postgresql version 11;
- B4A version 8.5;
- B4J version 6.8;
- Server (JRDC2 and Postgresql) Windows Server 2016.

P.S: Attachment file config with insert command that is running: sql.insert_people = INSERT INTO pessoas VALUES (?,?).

Thanks!
 

Attachments

  • Image_error.JPG
    Image_error.JPG
    107.9 KB · Views: 155
  • config.txt
    1.3 KB · Views: 150

Ederson Kerber

Member
Licensed User
Hi,

Here is the Insert command used:

Sub InsertRecord (nome As String, idade As Int)
Dim cmd As DBCommand = CreateCommand("insert_pessoas", Array(nome, idade))
Dim j As HttpJob = CreateRequest.ExecuteBatch(Array(cmd), Null)
Wait For(j) JobDone(j As HttpJob)
If j.Success Then
Log("Inserted successfully!")
End If
j.Release
End Sub


What do you see in the server output?
Sorry, how can I check this?

Thanks!
 
Upvote 0

josejad

Expert
Licensed User
Longtime User
Use code tags to show your code.
You can check the server output in the B4J log (you have to run the jRDC2 from B4J).

¿Do you have an index field in the database? I have problems too if I don't specify the fields name, because of the index field.

Try

B4X:
sql.insert_people = INSERT INTO pessoas (`nome`, `idade`) VALUES (?,?)

(change `nome`, `idade` for the real database field names)
 
Upvote 0

Ederson Kerber

Member
Licensed User
Hi,

¿Do you have an index field in the database? I have problems too if I don't specify the fields name, because of the index field.

I do not have a primary key, because a simple test table has been created.

You can check the server output in the B4J log (you have to run the jRDC2 from B4J).

I installed and configured B4J on the server to check the log. I reinstalled Oracle JDK 8. After this process I was able to insert normally with the command below:
B4X:
sql.insert_pessoas=INSERT INTO pessoas VALUES(?, ?)

Thanks @José J. Aguilar Problem solved!
 
Upvote 0
Top