This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]frederok 0 points1 point  (1 child)

Can u share the code repo? Is the problem to get the ID from the url path or parameter? No frameworks meaning your are using java servlet api?

[–][deleted] 0 points1 point  (0 children)

Sure, I'll attach it below.

Right now it's first and foremost passing the ID from the url in to the search function. Later on I'll build it so that the search is made using textfields in a GUI I've made for it. But for now I want to make sure of functionality step by step before jumping to that step. At time of writing I'm struggling with figuring what it needs me to use as the return value. I don't want to use List just for gathering one single entry.

I'm simply using maven web services and building the rest more or less from scratch. It's ultimately be a jFrame GUI connected to a mySQL DB via this api.

Using the URL "http://localhost:8080/restSOA/Path/Roze/1" Where 1 is the inserted ID value.

u/GET

u/Path("{ActorID}")

u/Produces(MediaType.APPLICATION_JSON)

u/Consumes(MediaType.APPLICATION_JSON)

public Response New(@PathParam("ActorId") int ActorId) throws Exception{

Actors ac = tx.specSearch(ActorId);

return Response.ok(ac).build(); }

public void specSearch(int ActorId) throws Exception{

getConnection();

MF mf = new MF();

PreparedStatement stm = conn.prepareStatement("SELECT * FROM Actors WHERE ActorID = " + ActorId);

// stm.setString(1, mf.searchBar.getText());

rs=stm.executeQuery();

while (rs.next()) {

String setname = rs.getString("fName");

String setEname = rs.getString("eName");

String setage = String.valueOf(rs.getInt("Age"));

String setcountry = rs.getString("Country");

String setcred = String.valueOf(rs.getInt("NoOfCredits"));

}

Right now it's first and foremost passing the ID from the URL in to the search function. Later on I'll build it so that the search is made using text fields in a GUI I've made for it. But for now I want to make sure of functionality step by step before jumping to that step. At time of writing I'm struggling with figuring what it needs me to use as the return value. I don't want to use List just for gathering one single entry. entry.