【Java开源代码栏目提醒】:网学会员Java开源代码为您提供ysfFood.java参考,解决您在ysfFood.java学习中工作中的难题,参考学习。
package flashRemoting.ysf;
import java.sql.*;
import java.io.*;
import java.io.Serializable;
import java.io.StringReader;
import org.xml.sax.InputSource;
import java.util.*;
import javax.sql.*;
import javax.naming.*;
import sun.jdbc.rowset.*;
import org.w3c.dom.*;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.
xml.parsers.DocumentBuilder;
public class ysfFood
extends ysfLogin
implements Serializable {
private Node nd;
private Node childNd;
private NodeList childNlst;
private NamedNodeMap nnm;
private String sqlStmt = null;
public ysfFood() {}
public ResultSet ProductionInfo(Object product_kind) throws Exception {
Connection connection = null;
PreparedStatement stmt = null;
ResultSet rs = null;
CachedRowSet crs = new CachedRowSet();
String sql = "select productName from productDetail WHERE productKind = '" + product_kind + "'";
System.out.println(sql);
try {
Context ctx = (Context) new InitialContext().lookup("java:comp/env");
DataSource ds = (DataSource) ctx.lookup("ysfDb");
connection = ds.getConnection();
stmt = connection.prepareStatement(sql);
rs = stmt.executeQuery();
crs.populate(rs);
crs.last();
System.out.println("RowSet populated.");
}
catch (Exception e) {
System.out.println(e);
}
finally {
try {
rs.close();
stmt.close();
connection.close();
}
catch (Exception e) {}
}
return crs;
}
public ResultSet ProductionKind() throws Exception {
Connection connection = null;
PreparedStatement stmt = null;
ResultSet rs = null;
CachedRowSet crs = new CachedRowSet();
String sql = "select DISTINCT productKind from productDetail";
try {
Context ctx = (Context) new InitialContext().lookup("java:comp/env");
DataSource ds = (DataSource) ctx.lookup("ysfDb");
connection = ds.getConnection();
stmt = connection.prepareStatement(sql);
rs = stmt.executeQuery();
crs.populate(rs);
crs.last();
System.out.println("RowSet populated.");
}
catch (Exception e) {
System.out.println(e);
}
finally {
try {
rs.close();
stmt.close();
connection.close();
}
catch (Exception e) {}
}
return crs;
}
public ResultSet ProductionDetail(Object product_name) throws Exception {
Connection connection = null;
PreparedStatement stmt = null;
ResultSet rs = null;
CachedRowSet crs = new CachedRowSet();
if (product_name != null) {
String
sql = "select * from productDetail WHERE productName = '" + product_name +
"'";
try {
Context ctx = (Context) new InitialContext().lookup("java:comp/env");
DataSource ds = (DataSource) ctx.lookup("ysfDb");
connection = ds.getConnection();
stmt = connection.prepareStatement(sql);
rs = stmt.executeQuery();
crs.last();
crs.populate(rs);
System.out.println("RowSet populated.");
}
catch (Exception e) {
System.out.println(e);
}
finally {
try {
rs.close();
stmt.close();
connection.close();
}
catch (Exception e) {}
}
}
return crs;
}
public boolean ProductionBuy(String userName, String userPass,
String Buy_xml) throws
Exception {
//鑾峰緱涓涓猉ML鏂囦欢鐨勮В鏋愬櫒
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
//涓鸿В鏋怷ML瀛楃涓茬敓鎴怐OM鏂囨。鐨勬帴鍙g被锛屼互渚胯闂瓺OM銆?
DocumentBuilder builder = factory.newDocumentBuilder();
//鏍规嵁瀛楃涓插垱寤轰竴涓猄tringReader瀹炰緥
StringReader XMLReader = new StringReader(Buy_xml);
//鏍规嵁StringReader瀹炰緥鍒涘缓涓涓狪nputSource瀹炰緥
InputSource XMLInputSource = new InputSource(XMLReader);
//瑙f瀽XML瀛楃涓?
Document Doc = builder.parse(XMLInputSource);
//鑾峰緱Root鍏冪礌
Element rt = Doc.getDocumentElement();
//鑾峰緱Root鍏冪礌鐨勫瓙鑺傜偣鍒楄〃
String sqlStatement = "";
Connection connection = nu