I have a jersey client which needs to perform DML operation on a remote database server. I have created jersey web service which takes argument as a string(i.e. query to be passed by client). I don't know how should I do it. Please help me. Thanks in advance.!
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import javax.ws.rs.Path;
import oracle.sql.CLOB;
@Path("/insertupdate")
public class InsertUpdate {
/**
* Inserts inclusion detail in Database
* @param insertQuery
* @param inclusionScript
*
*/
@Path("/insertInclusions")
public void insertInclusions(String insertQuery, String inclusionString) {
DbConnection con = null;
Connection conn = null;
PreparedStatement insertSt = null;
try {
con = new DbConnection();
conn = con.dbConnect();
insertSt = conn.prepareStatement(insertQuery);
CLOB tempClob = CLOB.createTemporary(conn, false,
CLOB.DURATION_SESSION);
tempClob.putChars(1, inclusionString.toCharArray());
insertSt.setClob(1, tempClob);
insertSt.execute();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
try {
// insertSt.close();
if (insertSt != null)
insertSt.close();
} catch (SQLException sqlExp) {
sqlExp.printStackTrace();
}
}
}
}