AF
HomeTagSubmit NotesAsk AnythingLoginSubscribe Us
AF
1. Feel Free to ask and submit anything on Anyforum.in and get satisfactory answer
2. Registration is not compulsory, you can directly login via google or facebook
3. Our Experts are looking for yours ?.



corejava-jdbc: How to get Balance of card

ex.
Sr.....Debit.......Credit.....Balance.

1......100.........0..........100.....
2......100.........0..........200.....
3......0...........50.........150.....
4......100.........0..........250.....

<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%@page import="java.sql.*"%>
<%@ page import="java.util.Calendar" %>
<%
//java Code
String date = (new java.util.Date()).toString();
String UserName = request.getParameter("UserName");
String CusId= request.getParameter("CusId");
String AccountNo = request.getParameter("AccountNo");
String Debit = request.getParameter("Debit");
String Credit=request.getParameter("Credit");
String Balance=request.getParameter("Balance");
String sDate=request.getParameter("sDate");
try
{
String s="jdbc:odbc:Database1";
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn=DriverManager.getConnection(s);
Statement smt=conn.createStatement();
Calendar calendar = Calendar.getInstance();
java.sql.Date startDate = new java.sql.Date(calendar.getTime().getTime());
String sql= "SELECT sDate, (SUM(Debit)*-1) + SUM(Credit)Balance FROM
abcbank GROUP BY sDate";
ResultSet result = smt.executeQuery(sql);
int count = 0;
while (result.next())
{
result.getString(1,"Debit");
result.getString(2,"Credit");
result.getString(3,"Balance");
result.getDate(4,startDate);

}

String update= "UPDATE abcbank SET Balance =Debit + Balance WHERE
AccountNo="+AccountNo+" ";
PreparedStatement statement = conn.prepareStatement(update);
//statement.setString(1,"AccountNo");
int rowsUpdated = statement.executeUpdate();
if (rowsUpdated ==0)
{
out.println("This Emp does not Exists!");
}
else if(rowsUpdated ==1)
{
out.println("An existing user was updated successfully!");
}
conn.close();
}
catch(Exception ex)
{
System.err.println(ex.getMessage());
}

%>

Answer the above query as early as possible.

corejava x 336
jdbc x 32
Posted On : 2016-11-24 06:59:18.0
profile MOHAMMAD SALEEM BASHA - anyforum.in MOHAMMAD SALEEM BASHA
266150
up-rate
4
down-rate

Answers


Please refer below link:

How to get Account Balance- Click Here

and

remove these methods

result.getString(1,"Debit");
result.getString(2,"Credit");
result.getString(3,"Balance");
result.getDate(4,startDate);

All are don´t even exist. use rs.getInt(1) to get the balance and proceed further as in above link.

Posted On : 2016-11-25 00:05:46
Satisfied : 0 Yes  0 No
profile Rishi Kumar - anyforum.in Rishi Kumar
523185319307
Reply This Thread
up-rate
0
down-rate



Post Answer
Please Login First to Post Answer: Login login with facebook - anyforum.in