I am really really confused about how to convert string data that I get from a form and convert it to a XMLstring and pass the XML string to a stored procedure in Java. Please help me out.
So, Let's say:-
Post () method-
String a = request.getParameter("FirstName");
String b = request.getParameter("LastName");
Now, stored procedure expects three parameters:-
a. firstname
b. lastname
c. Details - xml datatype
mystmt = conn.prepareCall("{call p_addeditcustomer(?,?,?)}");
mystmt.setString("FirstName",a);
mystmt.setString("LastName",b);
mystmt.setString("Details",details);
mystmt.executeQuery();
Now here is the problem this is what the details parameter expects in xml format
details-
<Table1>
<FirstName>a</FirstName>
<LastName>b</LastName>
</Table1>
How do I convert the above fields into that xml string and pass it to the stored procedure please help me out? I am a beginner in JSP and servlets.
For testing purpose I tried to pass the following String in a xml format but still it doesn't work
String details = "<Table1> " + "<CustomerId> 10123</CustomerId>" + "</Table1>;
1 Answer(s)