Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7196301
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:45:10+00:00 2026-05-28T20:45:10+00:00

I have a prepared statement in my database called BalanceOnDate and when I tried

  • 0

I have a prepared statement in my database called BalanceOnDate and when I tried to call it from following method I get following error, I tried hard to figure it out but I don’t see any clue for the solution please assist me,

public void fillClosingMontBalance(Month closingMonth) throws Exception {
        Connection con = connection;
        CallableStatement csForPreMonth = (CallableStatement) connection.prepareCall("{call BalanceOnDate(?,?,?)}");

        for (Iterator i = ledgerList.iterator(); i.hasNext();) {
            Ledger ledger = (Ledger) i.next();
            csForPreMonth.setString(1, "St_" + ledger.getStockType());
            csForPreMonth.setString(2, ledger.getFullLedgerNo());
            csForPreMonth.setString(3, closingMonth.getFullDate());
            ResultSet curRs = csForPreMonth.executeQuery();
            curRs.last();

            MonthEndBalance endBalance = new MonthEndBalance(curRs.getString("itmTyp"), curRs.getString("fulItmCode"),
                    curRs.getDouble("op_Balance"), curRs.getDouble("balance"), curRs.getDouble("total_received"),
                    curRs.getDouble("total_issued"), curRs.getString("unit"), curRs.getString("batchNo"),
                    curRs.getDouble("rawPrice"), curRs.getDouble("avg_unit_price"), curRs.getDate("sysDateTime"),
                    curRs.getString("facCode"), curRs.getString("comCode"), curRs.getString("fullLedgerNo"),
                    curRs.getString("stockType"), curRs.getString("fullItemName"));
            closingMonthRecords.add(endBalance);
        }
    }

Error;

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: FUNCTION BalanceOnDate does not exist
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
        at com.mysql.jdbc.Util.handleNewInstance(Util.java:409)
        at com.mysql.jdbc.Util.getInstance(Util.java:384)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1054)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3562)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3494)
        at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1960)
        at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2114)
        at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2690)
        at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2619)
        at com.mysql.jdbc.StatementImpl.executeQuery(StatementImpl.java:1465)
        at com.mysql.jdbc.DatabaseMetaData.getCallStmtParameterTypes(DatabaseMetaData.java:1602)
        at com.mysql.jdbc.DatabaseMetaData.getProcedureOrFunctionColumns(DatabaseMetaData.java:4141)
        at com.mysql.jdbc.DatabaseMetaData.getProcedureColumns(DatabaseMetaData.java:4059)
        at com.mysql.jdbc.CallableStatement.determineParameterTypes(CallableStatement.java:830)
        at com.mysql.jdbc.CallableStatement.<init>(CallableStatement.java:628)
        at com.mysql.jdbc.JDBC4CallableStatement.<init>(JDBC4CallableStatement.java:49)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
        at com.mysql.jdbc.Util.handleNewInstance(Util.java:409)
        at com.mysql.jdbc.CallableStatement.getInstance(CallableStatement.java:524)
        at com.mysql.jdbc.ConnectionImpl.parseCallableStatement(ConnectionImpl.java:4081)
        at com.mysql.jdbc.ConnectionImpl.prepareCall(ConnectionImpl.java:4165)
        at com.mysql.jdbc.ConnectionImpl.prepareCall(ConnectionImpl.java:4139)
        at Manufacturing.MonthEnd.FinishMonth.fillPreviousMonthBalanceRec(FinishMonth.java:69)
        at COMMON.FrmMDI.jButton4ActionPerformed(FrmMDI.java:4117)
        at COMMON.FrmMDI.access$14300(FrmMDI.java:72)
        at COMMON.FrmMDI$96.actionPerformed(FrmMDI.java:1678)
        at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2012)
        at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2335)
        at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:404)
        at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
        at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:253)
        at java.awt.Component.processMouseEvent(Component.java:6203)
        at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
        at java.awt.Component.processEvent(Component.java:5968)
        at java.awt.Container.processEvent(Container.java:2105)
        at java.awt.Component.dispatchEventImpl(Component.java:4564)
        at java.awt.Container.dispatchEventImpl(Container.java:2163)
        at java.awt.Component.dispatchEvent(Component.java:4390)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4461)
        at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4125)
        at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4055)
        at java.awt.Container.dispatchEventImpl(Container.java:2149)
        at java.awt.Window.dispatchEventImpl(Window.java:2478)
        at java.awt.Component.dispatchEvent(Component.java:4390)
        at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:649)
        at java.awt.EventQueue.access$000(EventQueue.java:96)
        at java.awt.EventQueue$1.run(EventQueue.java:608)
        at java.awt.EventQueue$1.run(EventQueue.java:606)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:105)
        at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:116)
        at java.awt.EventQueue$2.run(EventQueue.java:622)
        at java.awt.EventQueue$2.run(EventQueue.java:620)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:105)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:619)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:275)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:200)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:185)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:177)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:138)

following is my stored procedure in the database,

-- --------------------------------------------------------------------------------
-- Routine DDL
-- --------------------------------------------------------------------------------
DELIMITER $$

CREATE DEFINER=`user1`@`localhost` PROCEDURE `BalanceOnDate`(stname varchar(20),ledno varchar(100), fDate Varchar(12))
BEGIN
set @x = concat('
SELECT 
Ledger.`StockType` AS Ledger_StockType,
Ledger.`FullLedgerNo` AS Ledger_FullLedgerNo,
Ledger.`BackLedgerNo` AS Ledger_BackLedgerNo,
Ledger.`ForwdLedgerNo` AS Ledger_ForwdLedgerNo,
Ledger.`OpeningBalance`AS Ledger_OpeningBalance,
Ledger.`ClosingBalance`AS Ledger_ClosingBalance,
Ledger.`Unit` AS Ledger_Unit,
Ledger.`User` AS Ledger_User,
Ledger.`ItemType` AS Ledger_ItemType,
Ledger.`Active` AS Ledger_Active,
Ledger.`FullITCode` AS Ledger_FullITCode,
St.`ID` AS St_BFG_ID,
St.`InQty` AS St_BFG_InQty,
St.`OutQty` AS St_BFG_OutQty,
round(St.InQ - St.OuQ, 2) as Balance,
St.`Remarks` AS St_BFG_Remarks,
St.`BatchNo` AS St_BFG_BatchNo,
St.`EventNo` AS St_BFG_EventNo,
St.`FrToLedgerNo` AS St_BFG_FrToLedgerNo,
St.`FrmEvent` AS St_BFG_FrmEvent,
St.`User` AS St_BFG_User,
St.`Dat` AS St_BFG_Dat,
St.`Unit` AS St_BFG_Unit,
St.`RawPrice` as St_row_price,
St.`Uprice` as UnitPrice,
St.`Balance` as St_balance,
item_grade.`FulItmName` AS item_grade_FulItmName,
Company.`CompanyName` AS Company_CompanyName,
Factory.`Factory` AS Factory_Factory,
St.`SupID` AS St_BFG_SupID 
FROM (SELECT @inCsum:=0,@outCsum:=0) as xyz,
(SELECT @inCsum := @inCsum + InQty as InQ,@outCsum := @outCsum + OutQty as OuQ,d.*
FROM ',stname,' d WHERE FullLedgerNo= "',ledno,'" and Dat <= "', fDate ,'" ORDER BY Dat, SupID) as St
LEFT OUTER JOIN `Ledger` as Ledger ON St.`FullLedgerNo` = Ledger.`FullLedgerNo`     
LEFT OUTER JOIN `item_grade` item_grade ON Ledger.`FullITCode` = item_grade.`FulItmCode`
LEFT OUTER JOIN `Factory` Factory ON St.`FacCode` = Factory.`FacCode` 
LEFT OUTER JOIN `Company` Company ON Ledger.`ComCode` = Company.`ComCode` 
WHERE  Ledger.`FullLedgerNo` = "',ledno,'" and St.`Unit` = Ledger.`Unit`');
PREPARE stmt FROM @x;
    EXECUTE stmt;
    DEALLOCATE PREPARE stmt;
END
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T20:45:11+00:00Added an answer on May 28, 2026 at 8:45 pm

    Check that the user account passed when creating the connection has been granted execute privileges on BalanceOnDate.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can I have a prepared statement with the following query: select * from table
Is it possible to have a MySQLi prepared statement within the fetch() call of
How can I run a prepared statement against a database and have the returned
I have a prepared statement. I call stmt.setBigDecimal(BigDecimal.valueOf(0.9)) the problem is that in the
I have the following code : $id = $_GET['id']; // get the recod from
We have a Prepared Statement in Java and we hear that it is different
I Have a prepared statement INSERT INTO mst(time) VALUES (?); where time is of
The JDBC 3.0 spec talks about Connection (and Prepared Statement) pooling. We have several
I have a function that I use called sqlf(), it emulates prepared statements. For
I have a problem with my database class. I have a method that takes

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.