Databases Reference
In-Depth Information
int poid=rs.getInt(1)+1;
porder=createPorder(poid);
System.out.println(porder);
PreparedStatement pstmt=con.prepareStatement("Insert into
purchaseorder(poid, status, custid, porder)
values(?,?,?,XMLPARSE(document cast(? as varchar(5000))))");
pstmt.setInt(1,poid);
pstmt.setString(2,"unshipped");
pstmt.setInt(3,cid);
pstmt.setString(4,porder);
pstmt.executeUpdate();
con.commit();
con.close();;
return poid;
} catch (SQLException e) {
System.out.println(e.getMessage());
System.out.println(e.getErrorCode());
e.printStackTrace();
return 0;
}
} // updateTable
// createPorder calls a stored procedure to create the XML
// document for porder XML column value
public String createPorder(int poid)
{
CallableStatement cstmt;
String cart="cart"+cid;
try {
cstmt = con.prepareCall("call createOrder(?,?,?)");
cstmt.setInt(1,poid);
cstmt.setString(2,cart);
cstmt.registerOutParameter(3, Types.VARCHAR);
cstmt.executeUpdate();
return cstmt.getString(3);
} catch (SQLException e) {
System.out.println(e.getMessage());
System.out.println(e.getErrorCode());
e.printStackTrace();
return null;
}
} // createPorder
Search WWH ::




Custom Search