Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Arnold Scott   on Nov 20 In Java Category.

  
Question Answered By: Myrna Brown   on Nov 20

i am pasting my code pls  look into that mena
while i will go a head with ur suggetion.


code---

MiniBundleDTO mbundleDTO = new MiniBundleDTO();
String strArr[] = new String[2];
String SP_ADD_BUNDLE =
"{call "+PMConstants.SP_ADD_BUNDLE+
"(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)}";
logger.info("PMConstants.SP_ADD_BUNDLE:-"+ SP_ADD_BUNDLE);
try {

connection = getDataSource().getConnection();
logger.info("PMConstants.SP_ADD_BUNDLE:-
"+PMConstants.SP_ADD_BUNDLE);
//cstmt = connection.prepareCall(PMConstants.SP_ADD_BUNDLE);
cstmt = connection.prepareCall(SP_ADD_BUNDLE);
cstmt.registerOutParameter(1, OracleTypes.NUMERIC);
/* Bind parameters  sequentially to the callable statement to
be
*passed to the oracle StoredProcedure
*/
strArr = listToString(bundleDTO.getOfferingItems());
logger.debug("strArr:-"+strArr[0]);
cstmt.setString(2, strArr[0]); //passing offering ids
cstmt.setString(3, strArr[1]); //passing offering prices
logger.debug("strArr1:-"+strArr[1]);


/*
cstmt.registerOutParameter(10, OracleTypes.NUMERIC);
cstmt.registerOutParameter(11, OracleTypes.NUMERIC);
cstmt.registerOutParameter(12, OracleTypes.NUMERIC);
cstmt.registerOutParameter(13, OracleTypes.NUMERIC);
*/

cstmt.setString(4, bundleDTO.getBundleName());
logger.debug("getBundleName "+bundleDTO.getBundleName());
cstmt.setString(5, bundleDTO.getBundleDesc());
logger.debug("getBundleDesc "+bundleDTO.getBundleDesc());
cstmt.setString(6, bundleDTO.getLoginId()); //passing created
by
logger.debug("getLoginId "+bundleDTO.getLoginId());
short isBundle = 0;
if(bundleDTO.getProductCategoryDTO().getIsBundle()) {
isBundle = 1;
} else {
isBundle = 0;
}
logger.debug("isBundle "+ isBundle);
cstmt.setShort(7, isBundle);
cstmt.setLong(8, bundleDTO.getSourceDTO().getSourceId());
logger.debug("getSourceId "+ bundleDTO.getSourceDTO
().getSourceId());
long viewTypeId = bundleDTO.getViewtypeDTO().getViewTypeId();
cstmt.setLong(9, viewTypeId);
logger.debug("getViewTypeId "+ bundleDTO.getViewtypeDTO
().getViewTypeId());

//cstmt.registerOutParameter(1,OracleTypes.NUMBER); /casing error


cstmt.registerOutParameter(1, java.sql.Types.NUMERIC); //causing error
//cstmt.registerOutParameter(11, OracleTypes.NUMBER);
//cstmt.registerOutParameter(12, OracleTypes.NUMBER);
//cstmt.registerOutParameter(13, OracleTypes.NUMBER);

logger.info("kaladhar");
cstmt.execute();//going to sql  exception
logger.info("kaladhar1");


long intRetId = cstmt.getLong(1); // Get the Return Error
Code -1
logger.info("OracleBundleDAO:insertBundle()--intRetId" +
intRetId);
if (intRetId == -1) {
logger.error("OracleBundleDAO :- Dupicate Entry :" +
"Bundle Name = " +
bundleDTO.getBundleName());
throw new PMDataException
(PMConstants.MSG_DUPLICATE_BUNDLE);
} else if (intRetId == -2) {
logger.error("OracleBundleDAO :- Offering Id Exists :" +
" BundleName = " +
bundleDTO.getBundleName());
throw new PMDataException
(PMConstants.MSG_OFFERING_ID_NOT_EXIST);
} else {
miniBundleDTO.getProductCategoryDTO().
setProductCategoryId(cstmt.getLong(10));
miniBundleDTO.setwasNewPCReqd((cstmt.getShort(11)==1)?
true:false);
logger.info("OracleBundleDAO:insertBundle()--
setwasNewPCReqd" +
miniBundleDTO.getwasNewPCReqd());
miniBundleDTO.setBundleId(cstmt.getLong(12));
miniBundleDTO.getProductCategoryDTO().getServiceTypeDTO
().
setServiceTypeId(cstmt.getLong(13));
return miniBundleDTO;
}

} catch (SQLException sqe) {
logger.error("SQLException in OracleBundleDAO: " + sqe +
"SP name: " + PMConstants.SP_ADD_BUNDLE + "Bundle Name: "
+
bundleDTO.getBundleName());
throw new PMDataException(sqe);
} catch (Exception e) {
throw new PMDataException("Generic exception  in insertBundle"
+
"method of OracleBundleDAO" + e);
} finally {
// Cleaning up all the jdbc System resources
// Calling the Close Method of the DAOObject
logger.info(new ExitStringBuilder
("OracleBundleDAO:insertBundle()"));
close(cstmt, null, connection);


oracle SP- fields--

SQL_CODE OUT NUMBER,
OFFERINGIDS IN VARCHAR2,
BUNDLEOFFPRICES IN VARCHAR2,
BUNDLENAME IN BUNDLE.BUNDLE%TYPE,
BUNDLEDESCRIPTION IN BUNDLE.BUNDLE_DESCRIPTION%TYPE,
LOGINNAME IN
PARTY_SECURITY.SECURITYSTRING%TYPE,
ISBUNDLE IN NUMBER,
SOURCEID IN SOURCE.SOURCE_ID%TYPE,
VIEWTYPEID IN VIEW_TYPE.VIEW_TYPE_ID%
TYPE,
PRODUCTCATEGORYID OUT
PRODUCT_CATEGORY.PRODUCT_CATEGORY_ID%TYPE,
CATEGORYWASADDED OUT NUMBER,
BUNDLEID OUT BUNDLE.BUNDLE_ID%TYPE,
SERVICETYPEID OUT
SERVICE_TYPE.SERVICE_TYPE_ID%TYPE

Share: 

 

This Question has 2 more answer(s). View Complete Question Thread