forked from mishrkavita/Online-Banking-System-using-Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEnquireTransaction.java
More file actions
70 lines (63 loc) · 2.07 KB
/
EnquireTransaction.java
File metadata and controls
70 lines (63 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package com.mishra;
import java.util.*;
import java.sql.*;
import com.mishra.*;
public class EnquireTransaction {
private String UName, StartDate, EndDate;
private Vector C_Names, Rows;
public Vector[] FetchTransaction(String Uname,String StartDate,String EndDate) {
boolean done = !StartDate.equals("") && !EndDate.equals("");
try {
Vector C_Names = new Vector();
Vector Rows = new Vector();
if (done)
{
C_Names.addElement("Trans_Number");
C_Names.addElement("Trans_Amount");
C_Names.addElement("Trans_Time");
C_Names.addElement("Trans_Date");
C_Names.addElement("From_Acc");
C_Names.addElement("To_Acc");
C_Names.addElement("Trans_Type");
DBConnection ToDB = new DBConnection();
Connection DBConn = ToDB.openConn();
Statement stmt = DBConn.createStatement();
String SQL_Command = " SELECT * FROM Transactions WHERE CustomerID = '"+UName+"' AND TransactionDate BETWEEN '"+StartDate+"' AND '"+EndDate+"'";
ResultSet rslt = stmt.executeQuery(SQL_Command);
ResultSetMetaData rsmd = rslt.getMetaData();
while(rslt.next())
{
DBConnection DC = new DBConnection();
Rows.addElement(DC.getNextRow(rslt,rsmd));
int CN = rsmd.getColumnCount();
for (int i = 0; i<=CN; i++)
{
C_Names.addElement(rsmd.getColumnName(CN));
}
}
stmt.close();
ToDB.closeConn();
}
}
catch(java.sql.SQLException e)
{done = false;
System.out.println("SQLException: " + e);
while (e != null)
{System.out.println("SQLState: " + e.getSQLState());
System.out.println("Message: " + e.getMessage());
System.out.println("Vendor: " + e.getErrorCode());
e = e.getNextException();
System.out.println("");
}
}
catch (java.lang.Exception e)
{done = false;
System.out.println("Exception: " + e);
e.printStackTrace ();
}
Vector[] TransInfo = new Vector[2];
TransInfo[0] = C_Names;
TransInfo[1] = Rows;
return TransInfo;
}
}