Advertisement
Guest User

Untitled

a guest
Oct 10th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.93 KB | None | 0 0
  1.  
  2. import java.sql.*;
  3. import java.io.*;
  4.  
  5. class Combined
  6. {
  7. int c1=2004;
  8. void InsertEmployee()
  9. {
  10. BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
  11. Connection con=null;
  12. PreparedStatement pmt=null;
  13. String query=null;
  14.  
  15. try
  16. {
  17. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  18. con=DriverManager.getConnection("Jdbc:Odbc:customerdsn","root","root");
  19. query="insert into customerdb values(?,?,?,?,?)";
  20. pmt=con.prepareStatement(query);
  21.  
  22. int Acc_no=c1++;
  23. int en=Integer.parseInt(System.console().readLine("PIN No. ="));
  24. String name=System.console().readLine("CUSTOMER NAME =");
  25. int s=Integer.parseInt(System.console().readLine("ACCOUNT BALANCE ="));
  26. String c=System.console().readLine("PASSWORD =");
  27.  
  28. //setting values to placeholders
  29.  
  30. pmt.setInt(1,en);
  31. pmt.setString(2,name);
  32. pmt.setInt(3,s);
  33. pmt.setString(4,c);
  34. pmt.setInt(5,c1);
  35.  
  36.  
  37. //execute query
  38.  
  39. int r=pmt.executeUpdate();
  40. if(r>0)
  41. System.out.println("RECORD INSERTED SUCCESSFULLY");
  42. else
  43. System.out.println("ERROR IN INSERTION!!!");
  44. }
  45. catch(ClassNotFoundException ce)
  46. {
  47. ce.printStackTrace();
  48. }
  49.  
  50. catch(SQLException se)
  51. {
  52. se.printStackTrace();
  53. }
  54. }
  55.  
  56.  
  57. void Deleteaccount()
  58. {
  59. BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
  60. Connection con=null;
  61. PreparedStatement pmt=null;
  62. String query=null;
  63.  
  64. try
  65. {
  66. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  67. con=DriverManager.getConnection("Jdbc:Odbc:customerdsn","root","root");
  68.  
  69. query= "delete from customerdb where pin=? and password=?";
  70. pmt=con.prepareStatement(query);
  71.  
  72. int en=Integer.parseInt(System.console().readLine("TO DELETE CUSTOMER ACCOUNT, ENTER PIN No. ="));
  73. String p=System.console().readLine("PASSWORD =");
  74.  
  75. //setting values to placeholders
  76. pmt.setInt(1,en);
  77. pmt.setString(2,p);
  78.  
  79. //execute query
  80.  
  81. int r=pmt.executeUpdate();
  82. if(r>0)
  83. System.out.println("RECORD DELETED SUCCESSFULLY");
  84. else
  85. System.out.println("ERROR IN DELETION!!!");
  86.  
  87.  
  88. }
  89. catch(ClassNotFoundException ce)
  90. {
  91. ce.printStackTrace();
  92. }
  93.  
  94. catch(SQLException se)
  95. {
  96. se.printStackTrace();
  97. }
  98. }
  99.  
  100.  
  101.  
  102. void UpdateEmployee()
  103. {
  104. Connection con = null;
  105. PreparedStatement pmt = null;
  106. String query = null;
  107. BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  108.  
  109. try
  110. {
  111.  
  112. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  113. con = DriverManager.getConnection("Jdbc:Odbc:customerdsn","root","root");
  114. query = "update customerdb set balance=balance+? where pin= ?";// here ? is to putany value
  115. pmt=con.prepareStatement(query);
  116.  
  117. int en=Integer.parseInt(System.console().readLine("PIN No. ="));
  118. int m=Integer.parseInt(System.console().readLine("ENTER AMOUNT TO DEPOSIT ="));
  119.  
  120. //setting values to place holders
  121.  
  122. pmt.setInt(1,m);
  123. pmt.setInt(2,en);
  124. //execute query
  125.  
  126. int r=pmt.executeUpdate();
  127. if(r>0)
  128. System.out.println("RECORD UPDATED SUCCESSFULLY");
  129. else
  130. System.out.println("ERROR IN UPDATION!!!");
  131. }
  132. catch(ClassNotFoundException ce)
  133. {
  134. System.out.println("CLASS NOT FOUND!!!");
  135. ce.printStackTrace();
  136. }
  137.  
  138. catch(SQLException se)
  139. {
  140. se.printStackTrace();
  141. }
  142. }
  143.  
  144.  
  145. void passchange()
  146. {
  147. Connection con = null;
  148. PreparedStatement pmt = null;
  149. String query = null;
  150. BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  151.  
  152. try
  153. {
  154.  
  155. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  156. con = DriverManager.getConnection("Jdbc:Odbc:customerdsn","root","root");
  157. query = "update customerdb set password=? where password= ?";// here ? is to putany value
  158. pmt=con.prepareStatement(query);
  159.  
  160.  
  161. String p=System.console().readLine("OLD PASSWORD=");
  162. String pa=System.console().readLine("NEW PASSWORD=");
  163.  
  164. //setting values to place holders
  165.  
  166. pmt.setString(2,p);
  167. pmt.setString(1,pa);
  168. //execute query
  169.  
  170. int r=pmt.executeUpdate();
  171. if(r>0)
  172. System.out.println("PASSWORD UPDATED SUCCESSFULLY");
  173. else
  174. System.out.println("ERROR IN UPDATION!!!");
  175. }
  176. catch(ClassNotFoundException ce)
  177. {
  178. System.out.println("CLASS NOT FOUND!!!");
  179. ce.printStackTrace();
  180. }
  181.  
  182. catch(SQLException se)
  183. {
  184. se.printStackTrace();
  185. }
  186. }
  187. void withdraw()
  188. {
  189. Connection con = null;
  190. PreparedStatement pmt = null;
  191. String query = null;
  192. BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  193.  
  194. try
  195. {
  196.  
  197. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  198. con = DriverManager.getConnection("Jdbc:Odbc:customerdsn","root","root");
  199. query = "update customerdb set balance=balance-? where pin= ? and password =?";// here ? is to putany value
  200. pmt=con.prepareStatement(query);
  201.  
  202. int en=Integer.parseInt(System.console().readLine("PIN No. ="));
  203. String p=System.console().readLine("PASSWORD =");
  204. int m=Integer.parseInt(System.console().readLine("ENTER AMOUNT TO WITHDRAW="));
  205. //setting values to place holders
  206.  
  207. pmt.setInt(1,m);
  208. pmt.setInt(2,en);
  209. pmt.setString(3,p);
  210. //execute query
  211.  
  212. int r=pmt.executeUpdate();
  213. if(r>0)
  214. System.out.println("AMOUNT WITHDRAWN SUCCESSFULLY");
  215. else
  216. System.out.println("ERROR IN WITHDRAW!!!");
  217. }
  218. catch(ClassNotFoundException ce)
  219. {
  220. System.out.println("CLASS NOT FOUND!!!");
  221. ce.printStackTrace();
  222. }
  223.  
  224. catch(SQLException se)
  225. {
  226. se.printStackTrace();
  227. }
  228. }
  229.  
  230. void display()
  231. {
  232.  
  233. Connection con=null;
  234. Statement stmt=null;
  235. ResultSet rs=null;
  236. String query=null;
  237.  
  238. try
  239. {
  240. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  241. con=DriverManager.getConnection("Jdbc:Odbc:customerdsn","root","root");
  242. stmt=con.createStatement();
  243. query="select * from customerdb";
  244. rs=stmt.executeQuery(query);
  245.  
  246. System.out.println("-------------------------------------------CUSTOMER RECORDS------------------------------------------\n\n PIN NAME BALANCE PASSWORD ACCOUNT NO.\n");
  247. System.out.println("=====================================================================================================");
  248. while(rs.next())
  249. {
  250. int pin=rs.getInt(1);
  251. String name=rs.getString(2);
  252. int bal=rs.getInt(3);
  253. String pass=rs.getString(4);
  254. int Acc_no=rs.getInt(5);
  255. System.out.printf("%8d |%18s |%18d |%20s |%17d\n",pin,name,bal,pass,Acc_no);
  256. System.out.println("------------------------------------------------------------------------------------------------------");
  257. }
  258. }
  259. catch(ClassNotFoundException ce)
  260. {
  261. ce.printStackTrace();
  262. }
  263.  
  264. catch(SQLException se)
  265. {
  266. se.printStackTrace();
  267. }
  268. }
  269.  
  270.  
  271.  
  272. void aboutus()
  273. {
  274. System.out.println("\t\tMy BANK IS INDIA'S LARGEST PRIVATE SECTOR BANK WITH\n\t\tTOTAL ASSETS OF RS. 6,461.29 BILLION (US$ 103 BILLION AT ");
  275. System.out.println("\t\tMARCH 31, 2015. My BANK CURRENTLY HAS A NETWORK OF\n\t\t4,050 BRANCHES AND 12,817 ATM's ACROSS INDIA.");
  276. System.out.println("\n\n\t\tBOARD MEMBERS\n\t\t-------------\n\t\tSHUBHRANSHU DWIVEDI\n\t\tPRATYUSH KAUSHIK\n\t\tPIYUSH MISHRA\n\n");
  277. }
  278.  
  279.  
  280.  
  281.  
  282. void contact()
  283. { System.out.println("\t\tCONTACT NO.- 9717486303, 7503781868\n\t\tEMAIL ID.- shubhranshukumar12@ymail.com\n\t\tADDRESS- IMS ENGINEERING COLLEGE,GHAZIABAD,UP");
  284.  
  285. }
  286. }
  287.  
  288.  
  289.  
  290.  
  291. class BankProject
  292. {
  293. public static void main(String args[])throws IOException
  294. {
  295. int chc=1;
  296. Combined c=new Combined();
  297. while (chc==1)
  298. { System.out.println("\n\t =* = * = * = * = * = * = * =* = * = * = * = * = * = * =* = * = * =* = * =* = * ");
  299. System.out.println("\t|| ||");
  300. System.out.println("\t||------------------------------WELCOME TO MY BANK---------------------------||");
  301. System.out.println("\t|| ||");
  302. System.out.println("\t =* = * = * = * = * = * = * =* = * = * = * = * = * = * =* = * = * = * = * =* = *\n\n\n\n");
  303.  
  304.  
  305.  
  306. System.out.println(" *+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*");
  307. System.out.println(" \t\t\t* *");
  308. System.out.println(" \t\t\t* MENU *");
  309. System.out.println(" \t\t\t*°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°*");
  310. System.out.println(" \t\t\t* *");
  311. System.out.println(" \t\t\t*\t1. NEW ACCOUNT *\n \t\t\t*\t2. DELETE ACCOUNT *\n \t\t\t*\t3. DEPOSIT AMOUNT *");
  312. System.out.println(" \t\t\t*\t4. WITHDRAW *\n \t\t\t*\t5. DISPLAY INFO *\n \t\t\t*\t6. CHANGE PASSWORD *\n \t\t\t*\t7. ABOUT US *\n \t\t\t*\t8. CONTACT US *");
  313. System.out.println(" \t\t\t* *");
  314. System.out.println(" *+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*\n\n");
  315. int ch=Integer.parseInt(System.console().readLine("\t\tENTER YOUR CHOICE: ="));
  316. System.out.println();
  317. switch(ch)
  318. {
  319. case 1:
  320. c.InsertEmployee();
  321. break;
  322. case 2:
  323. c.Deleteaccount();
  324. break;
  325.  
  326. case 3:
  327. c.UpdateEmployee();
  328. break;
  329.  
  330. case 4:
  331. c.withdraw();
  332. break;
  333.  
  334. case 5:
  335. c.display();
  336. break;
  337. case 6:
  338. c.passchange();
  339. break;
  340. case 7:
  341. c.aboutus();
  342. break;
  343. case 8:
  344. c.contact();
  345. break;
  346. default:
  347. System.out.println("wrong choice!!!!!");
  348. }
  349. System.out.println("\n\nENTER 1 TO REPEAT PROCEDURE ELSE ENTER 0\n\nTHANK YOU! FOR CHOOSING SHUBHRANSHU BANK\n");
  350.  
  351. chc=Integer.parseInt(System.console().readLine("choice ="));
  352.  
  353. }
  354. }
  355. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement