Solved

Error in Calling an Oracle Stored Procedure in Java

Posted on 2004-10-13
5
614 Views
Last Modified: 2008-01-09
Hi experts,

I am trying to call an oracle stored procedure in java...   However, I am encountering this error and I have no clue on what might gone wrong...    Hope you could help me...   Thanks in advance...!   =)

java.lang.NullPointerException
        at oracle.jdbc.ttc7.TTCAdapter.newTTCType(TTCAdapter.java:270)
        at oracle.jdbc.ttc7.TTCAdapter.createNonPlsqlTTCColumnArray(TTCAdapter.j
ava:256)
        at oracle.jdbc.ttc7.TTCAdapter.createNonPlsqlTTCDataSet(TTCAdapter.java:
231)
        at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1435)
        at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:888
)
        at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.ja
va:2051)
        at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.jav
a:1961)
        at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStateme
nt.java:2672)
        at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePrepar
edStatement.java:452)
        at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStat
ement.java:526)
        at ph.com.smart.crm.modules.prepaid.sales.DBAccess.createCRMQuote(DBAcce
ss.java:703)
        at ph.com.smart.crm.modules.prepaid.sales.DBAccess.createQuote(DBAccess.
java:195)
        at ph.com.smart.crm.modules.prepaid.sales.CreateQuoteProcessor.performTa
sk(CreateQuoteProcessor.java:159)
        at ph.com.smart.crm.modules.prepaid.sales.CreateQuoteProcessor.execute(C
reateQuoteProcessor.java:59)
        at ph.com.smart.crm.modules.prepaid.sales.ActionListener.execute(ActionL
istener.java:43)
        at ph.com.smart.common.servlet.CommonServlet.performTask(CommonServlet.j
ava:106)
        at ph.com.smart.common.servlet.CommonServlet.doGet(CommonServlet.java:47
)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
        at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletReque
stDispatcher.java:721)
        at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(Ser
vletRequestDispatcher.java:306)
        at com.evermind.server.http.HttpRequestHandler.processRequest(HttpReques
tHandler.java:767)
        at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.ja
va:259)
        at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.ja
va:106)
        at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExec
utor.java:803)
        at java.lang.Thread.run(Thread.java:534)



This is my java code...

strbufSQL = new StringBuffer();
strbufSQL.append(" {CALL CRM_CUSTOMER_TRXN_PKG.INSERT_QUOTE_HEADER(");
strbufSQL.append(" ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,");
strbufSQL.append(" ?, ?, ?, ?, ?, ?, ?, ?)}");
            
strSQL = strbufSQL.toString();
            
cstmt = connCRM.prepareCall(strSQL);
            
cstmt.registerOutParameter(19, Types.VARCHAR);
cstmt.registerOutParameter(22, Types.VARCHAR);

cstmt.setString(1, strOrderID);
cstmt.setString(2, strBranchCode);
cstmt.setString(3, strDocOwnerCode);
cstmt.setString(4, strAgentCode);
cstmt.setString(5, strCoordinatorCode);
cstmt.setString(6, strCustomerCode);
cstmt.setString(7, strCustomerName);
cstmt.setString(8, strPromoCode);
cstmt.setString(9, strBlitzCode);
cstmt.setString(10, strTotalQuantity);
cstmt.setString(11, strTotalDiscount);
cstmt.setString(12, strTotalAmount);
cstmt.setString(13, strSubSLOCCode);
cstmt.setString(14, strRemarks);
cstmt.setString(15, strOrderType);
cstmt.setString(16, strInvMoveID);
cstmt.setString(17, "");
cstmt.setString(18, "");
cstmt.setString(20, "");
cstmt.setString(21, strLoginID);

cstmt.execute();
            
strStatus = cstmt.getString(19);
strQuoteHeaderID = cstmt.getString(22);


This is my oracle stored procedure and is running using SQL Navigator or Toad or SQL Plus...

PROCEDURE Insert_Quote_Header(i_quote_code           IN crm_quote_header_tbl.quote_code%TYPE
                    ,i_WC_code             IN crm_quote_header_tbl.WC_code%TYPE DEFAULT NULL
                    ,i_doc_owner_code      IN crm_quote_header_tbl.doc_owner_code%TYPE DEFAULT NULL
                    ,i_agent_code          IN crm_quote_header_tbl.agent_code%TYPE DEFAULT NULL
                    ,i_emp_no      IN crm_quote_header_tbl.emp_no%TYPE DEFAULT NULL
                    ,i_cust_id       IN VARCHAR2
                    ,i_customer_name      IN crm_quote_header_tbl.customer_name%TYPE DEFAULT NULL
                    ,i_promo_code      IN crm_quote_header_tbl.promo_code%TYPE DEFAULT NULL
                    ,i_blitz_code      IN crm_quote_header_tbl.blitz_code%TYPE DEFAULT NULL
                    ,i_quantity      IN VARCHAR2
                    ,i_discount      IN VARCHAR2
                    ,i_quote_amt           IN VARCHAR2
                    ,i_sloc_code      IN crm_quote_header_tbl.sloc_code%TYPE DEFAULT NULL
                    ,i_remarks      IN crm_quote_header_tbl.remarks%TYPE DEFAULT NULL
                    ,i_order_type_code       IN crm_quote_header_tbl.order_type_code%TYPE DEFAULT NULL
                    ,i_inv_doc_id      IN VARCHAR2
                    ,i_quote_source_code  IN crm_quote_header_tbl.quote_source_code%TYPE DEFAULT NULL
                    ,o_quote_header_id    OUT VARCHAR2
                    ,i_service_type_code         IN crm_quote_header_tbl.service_type_code%TYPE DEFAULT NULL
                    ,i_user_id                IN VARCHAR2
                    ,o_Status            OUT VARCHAR2)

0
Comment
Question by:expert_mentos
5 Comments
 
LVL 15

Expert Comment

by:justinbillig
ID: 12298641
You have the Wrong TA, this is javascript ( the web scripting language ). Post in community support and ask them to move your Question to the Java TA
0
 
LVL 11

Accepted Solution

by:
cjjclifford earned 100 total points
ID: 12299314
To set null arguments, you should use:

cstmt.setNull( i, Types.XYZ )

e.g.

if( strBlitzCode != null ) {
    cstmt.setString(9, strBlitzCode);
}
else {
    cstmt.setNull( 9, Types.VARCHAR );
}
 
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now