Solved

Error in Calling an Oracle Stored Procedure in Java

Posted on 2004-10-13
5
613 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This video teaches viewers about errors in exception handling.

707 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

12 Experts available now in Live!

Get 1:1 Help Now