Skip to content
Advertisement

Pulling data from json inside mysql to java

So I have a claim script that I’m trying to put together, that claims the product after purchase. The program is built inside of Java. The problem I’m running into is that there is a custom field they input on their purchase, and the store itself inserts it into a JSON format. So I need to execute a query that pulls the custom field into the WHERE statement, like so :

JavaScript

So i need to insert into this Result Set the JSON I’m trying to pull from. This is what I’m trying to pull from the database and insert as the name to verify which user bought the product to claim.

Trying to pull "test"

I get the error :

JavaScript

which points to :

JavaScript

I need the execute to check the databse, find a row in which the name == the custom field “1”: variable, and where claimed == 0, and I will need to pull the ps_item_id from that row to execute inside another file. How do i properly access the array and check if the player name is == to the “1”: variable?

Advertisement

Answer

After trying multiple different ways, I found through JSON object how to parse the data. I had to initiate a first ResultSet, and than from that result set, pull the custom_field and than pull that into a JSON Object, parse the “1” to a string, and than use another ResultSet with that string to get that row

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement