基于WAS CE和Axis2开发Web Service应用
2010-03-19 00:00:00 来源:WEB开发网下面我们来重点看一下query方法的实现:
public OMElement query(OMElement in){
int flowerid = Integer.parseInt(in.getText());
String info = "Can not query!";
try {
//use axis2 datasource we deployed before
Context initContext = new InitialContext();
Context envContext = (Context)initContext.lookup("java:/comp/env");
DataSource ds = (DataSource)envContext.lookup("jdbc/DataSource");
Connection con = ds.getConnection();
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(
"SELECT * FROM FLOWER WHERE ID=" + flowerid );
while (rs.next())
{
info = "ID=" + rs.getInt("ID") + " NAME=" + rs.getString("NAME") +
" DESCRIPTION=" + rs.getString("DESCRI") + " PRICE=" +
rs.getDouble("PRICE");
}
} catch(Exception e) { }
//create the OMElement for response
OMFactory fac = OMAbstractFactory.getOMFactory();
OMNamespace omNs = fac.createOMNamespace("http://flowershop.com/", "flower");
OMElement resp = fac.createOMElement("getFlowerInfo", omNs);
resp.setText(info);
return resp;
}
- ››CentOS下配置超级终端minicom
- ››Centos6.2_x86_64环境下puppet-dashboard安装配置...
- ››CentOS下建立本地YUM源并自动更新
- ››基于IP地址的vsftp服务器
- ››CentOS 安装 PostgreSQL 9.2
- ››CentOS 6.3 安装 Oracle 11gR2 依赖库检查失败处理...
- ››CentOS 6.X 系统初始化生产脚本
- ››CentOS 6下安装nodejs 0.9.0教程
- ››CentOS使用Screen管理会话选项
- ››基于MySQL 水平分区的优化示例
- ››CentOS+JDK+Tomcat+MySql&JDBCDriver 开发环境搭建...
- ››CentOS 5.6创建NFS文件共享服务器
更多精彩
赞助商链接