B4J Question I'm working on a new KVS library, MySQL problem.

LWGShane

Well-Known Member
Licensed User
Longtime User
I'm working on a new KVS library (version 3.0) and am having a bit of a problem with the MySQL part of the library: I cannot Get an object that was serialized with my Put method.

I have created a test MySQL server so don't worry about the credentials being visible or weak, etc.
Project is attached. Any ideas?
 

Attachments

  • UniverseCore.zip
    4.4 KB · Views: 210

Erel

B4X founder
Staff member
Licensed User
Longtime User
1. You should use parameterized queries:
B4X:
Dim RS As ResultSet = SQL1.ExecQuery($"SELECT `Value` FROM `${Table}` WHERE `Key` = "${Key}""$)
This code will fail if the key includes a character that needs to be escaped and it is also vulnerable to SQL injections.

2. Same here:
B4X:
SQL1.ExecNonQuery($"REPLACE INTO `${Table}`(`Key`,`Value`) VALUES("${Key}","${Ser.ConvertObjectToBytes(Value)}")"$)
This code will not create a valid blob. You must use ExecNonQuery2.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…