我有一个需要在远程数据库服务器上执行 DML 操作的球衣客户端。我创建了 jersey web 服务,它将参数作为字符串(即客户端传递的查询)。我不知道我该怎么做。请帮我。提前致谢。!
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();
}
}
}
}