B4J Question INSERT Query end with a ERROR

Swissmade

Well-Known Member
Licensed User
Longtime User
Hi all,
What is wrong with this query??
strSQL = "INSERT INTO axisanpr.histimages (Image, Image1, Image2, Image3, ImageName) " _
& " VALUES ('" & "BlaBla" _ 'tmpImage _
& "', '" & "BlaBla" _ 'tmpImage1 _
& "', '" & "BlaBla" _ 'tmpImage2 _
& "', '" & "BlaBla" _ 'tmpImage3 _
& "', '" & "BlaBla" _ ' NewImageName _
& "');"

SQLDBCREATE.BeginTransaction
SQLDBCREATE.ExecNonQuery(strSQL)
SQLDBCREATE.TransactionSuccessful give me a error java.lang.NumberFormatException: For input string: "null"


Image, Image1, Image2, Image3 are LongText fields
ImageName = Varchar(255)

I use JSQL version 1.60
Some help can be nice thanks.
 
Last edited:

inakigarm

Well-Known Member
Licensed User
Longtime User
Hi all,
What is wrong with this query??
It's dificult for me to read this string as is, I suppose there's one null string in the query; have you log the strSQL to check the query string ?
First, I use in all the sql types string the Smart String literal, it's more readable.
Next, I'd have log the string and I'd tested it directly on DB if there was no strange formed string (sqlite ---》 dbbrowser sqlite for ex)
 
Upvote 0

Swissmade

Well-Known Member
Licensed User
Longtime User
It's dificult for me to read this string as is, I suppose there's one null string in the query; have you log the strSQL to check the query string ?
First, I use in all the sql types string the Smart String literal, it's more readable.
Next, I'd have log the string and I'd tested it directly on DB if there was no strange formed string (sqlite ---》 dbbrowser sqlite for ex)

Hi,
There is no null value in the string all is filled with data in this case BlaBla. The real data for this is a Base64 string so for testing its BlaBla
If I execute the query directly in the DB there is no problem.

Strange is, if I execute the query without BeginTransaction I get a error but the record is saved.

I use Maridb(MySQL)
 
Last edited:
Upvote 0

Swissmade

Well-Known Member
Licensed User
Longtime User
Found the error but it is very strange.
It have something to do with the IDE
I delete the hole SUB and retype it again.
Problem solved
Before I have copy past this SUB
 
Upvote 0

Swissmade

Well-Known Member
Licensed User
Longtime User
You should never write such queries. Use parameterized queries instead.

I don't understand whats wrong.

strSQL = "INSERT INTO axisanpr.histimages (Image, Image1, Image2, Image3, ImageName) " _
& " VALUES ('" & "BlaBla"
& "', '" & "BlaBla" _
& "', '" & "BlaBla" _
& "', '" & "BlaBla" _
& "', '" & "BlaBla" _
& "');"
What you mean with parameterized queries.
Thanks
 
Upvote 0

Swissmade

Well-Known Member
Licensed User
Longtime User
I see why thanks for the Hint Erel
 
Upvote 0
Top