How to iterate Json object from JDBC Request In Jmeter - java

I have used JDBC Request in JMeter to get the data from the MySQL table. The select query returns a JSON object like below:
{"HeaderKey":"BR023159537221170209370","ReceiptSequenceNumber":"6643182852","status":"Success"}
JDBC Request
I have to get the status key from the object. How I can achieve it using JDBC Request?
Thanks in advance.

According to JDBC Request sampler documentation the result will be stored into ${IHM_response_3_1} variable.
So you can extract the status from there using JSON Extractor configured like:
Once done you should be able to refer extracted value as ${status} where required

Related

Unable to create endpoint with JDBC mssql in java

I am trying to create endpoint in jsp, i have been able to connect to the database using the following code but i need to understand the structure of it.
<%
String refNumb = request.getParameter("refNumb");
// String display = request.getParameter("display");
//String msg = request.getParameter("message");
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection con = DriverManager.getConnection("jdbc:sqlserver://IPAddress;databaseName=FIRS",
"user", "pass");
%>
You have successfully done the first step which is to connect to your database via jdbc. You can follow these steps after you successful fetched records from the database.
Convert your records into json string in java, you can use json library and follow the steps on how to convert your records to json
Create a jsp file and use out.print to print the records on your browser.
If you can get to step two then final step is to give a use the url of your jsp which is the end point. As long as anyone can display the json data from your db then that data can easily be consume via js or any other programming language.
You can also research via google on how to implement and consume webservices in java(Soap or rest) and follow the tutorial step by step.

JAVA Apache Jena Fuseki: Create Endpoint via API, Retrieve all endpoints via API

i have two questions related to Apache Jena Fuseki.
The first one is:
I need to create an endpoint using the API (from java code, not from Fuseki UI). For "endpoint" i mean the dataset that fuseki allow to create using the UI, from http://localhost:xxxx/. I also need to make it persistent.
The second one:
consider that we have a list of dataset already created. I want to get the "label" of each existing endpoint (ex: dataset1, dataset56, testDataset ....).
I know how to query and update data from a specified endpoint, but i have no idea on how manage datasets (create/delete and also get the label).
Any suggestion will be appreciated.
EDIT1:
I've found a workaround
Retrieve dataset list by sending a GET request to http://localhost:3030/$/server
Create dataset by sending a POST request to http://localhost:3030/$/datasets
The following POST parameters must be set: "dbName=/dataseName&dbType=tdb"
dbType can be set either to mem (non persistent dataset) or tdb (persistent dataset).
Still trying to find a way to get the same results using a Jena API call.

How to protect servlet response data when directly accessed using URL

In my application I have used JSON auto suggest functionality to suggest name of user id when stored in cache.
So when ever I try to hit the URL the response is getting back the fully qualified email address, PFB -
Request - https://wwwsampleweb.com/tc/servlet/AjaxServiceServlet?qtc=james*
it is returning the response -
{identifier:'name', items: [ {name:'james.goodlife#abc.com', label:'james.goodlife#abc.com'}]}
How to stop the response when directly accessing the URL?
I have tried to verify the session but this servlet is used for auto sugggesting the username while logging in which means session is not created status. Also we can block the IP but we cannot block all IPs.
Could you please assist me how we can stop this?
Thanks!
I'm missing the value of username-suggesting at a login-form, but anyway;
I assume that you are requesting the data using a GET-request?
If you would like to prevent anyone from accessing the URL directly and retrieving data, you could use a POST-request and then only return data when the page is accessed through a POST-request (optionally combined with the session-check).
Please keep in mind that this is not a bullet-proof way of preventing use.

How to insert data into MySQL through a URL?

So I have a MySQL db called "Example". In the db, I have a table with a row called "Rank" and "Name". I want to be able to input "Rank" and "Name" values into the db through URL.
I have made a Tomcat server through Eclipse, and would like help on the java code in order to use the parameters to send data to the db.
Thanks in advance!
Java - sending HTTP parameters via POST method easily
The question itself shows a 'GET' method. the accepted answer shows a 'POST' method.
All the handling should be done on your server.
This is a code for sending it the right values to the server.
Do you need help with the server itself?
I know how to do that in php, if that helps you

How to read a php POST variable in Java

Is it possible read a POST variable set on a server in this way:
<?php
$_POST['Val'] = 'Ret_value';
?>
I need to do this with a Java client
According to PHP manual is a An associative array of variables passed to the current script via the HTTP POST method.
Modified POST variables are from what I know not included into the HTTP response. Setting them like in your example does not change anything on the server response.
Therefore what you are trying to do - sending data via $_POST from a PHP server to a Java client is not possible.
ServletRequest don't have setParameter() method, but it have setAttribute() whom you can use to pass some objects for next filter or servlet.
http://download.oracle.com/javaee/6/api/javax/servlet/ServletRequest.html#setAttribute%28java.lang.String,%20java.lang.Object%29

Categories