Android Question JdbcSQL failing insert with parameters

kgf

Member
Licensed User
Hi All

I am having trouble with inserting into Postgresql using JdbcSQL. I can select from postgres and insert into sqlite no problem but going the other way it fails silently and doesnt show any succes tru eor false. Using postgresql-42.2.4.jre7.

If I hardcode the Values it works fine, the below code works.
B4X:
Starter.pgsql.AddNonQueryToBatch("INSERT INTO mytable (id, diary_date, location, job_number) VALUES ('29EAA55B-E9CF-BB08-1EA6-4A27DD4B9A1E' ,'2020-08-17','location', 'abcde1');",Null)

However if i use parameters
B4X:
            Dim strSql As String = "INSERT INTO mytable (id, diary_date, location, job_number) VALUES (?,?,?,?)"
            Starter.pgsql.AddNonQueryToBatch(strSql, Array(idCol, Col2, Col3, Col4))

            Dim SenderFilter As Object = Starter.pgsql.ExecNonQueryBatch("SQL")
            Wait For (SenderFilter) SQL_NonQueryComplete (Success As Boolean)
            Log(Success)
            If Success = False Then
                Log(LastException)
            End If
Success dosent return anything and in the unfiltered logs I get
"Rejecting re-init on previously-failed class java.lang.Class<org.postgresql.util.GT>"

Anyone have any ideas
Thanks
 

OliverA

Expert
Licensed User
1) Try upping the minimum sdk version in the manifest
2) Make sure to include all external libraries and their dependencies (if you use any)
 
Upvote 0

kgf

Member
Licensed User
Currently manifest sdk version <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="28"/>

Have a couple of older devices on Android 5 so hoping to stay at 21

Not sure what you mean about including external libraries. Just have this for the driver
#AdditionalJar: postgresql-42.2.4.jre7
 
Upvote 0

OliverA

Expert
Licensed User
Not sure what you mean about including external libraries
I’m just fishing. Others seem to have similar error messages that are solved by including missing libraries. AppCompat seems to be mentioned often.

Is this happening in a small sample project? There are also hints about out of memory issues
 
Upvote 0

kgf

Member
Licensed User
using jdbcSql version 1.5. It does use appcompat but no other errors. It is a large project now, just at the last step of getting data from the device back to an inhouse database.
Have tried created a list of the parameters and using that as the args and also and as an array() but with anything othet than NUll as an arg it fails. Doesnt seem to have any menory issues, using jdbc to import several thousand records from postgres to the device but fails on trying to insert one!
 
Upvote 0

OliverA

Expert
Licensed User
If you have time, create a small example app, without app compat, and see if you can reproduce the issue.
 
Upvote 0

kgf

Member
Licensed User
Ok, thought id push on, created a new empty project without appcompat and copied the realvant parts but it has the same problem.
It will select from postgres but not insert using parameters.
First try it fails silently with no success or log message, second time it shows "Rejecting re-init on previously-failed class java.lang.Class<org.postgresql.util.GT>" in unfiltered logs.
 
Upvote 0
Top