program created and compilation error of connection rightly created n tested

program created and compilation error of connection rightly created n tested

// I have made connection as the data source dsn2 and i have also created table named Tab1 in SQL server 2008..it is compiled correctly but is giving error for connection on which other programs are running smoothly...:(

import java.awt.*; import java.awt.event.*; import java.awt.FlowLayout; import java.sql.*; import javax.swing.*; public class Bank extends JFrame

implements ActionListener { static JLabel label1,label2,label3,sep; static JButton

sign,create,deposit,withdraw,trans,balance,cl

ose,clear; static JTextField txtA1; static JTextField txtA2; static Connection con; static Statement st1,st2,st3; static ResultSet rs1; int numd; int numf; int nume; public Bank() { super(" Mukunth's Bank"); setLayout(new FlowLayout()); try { Class.forName

("sun.jdbc.odbc.JdbcOdbcDriver"); con =

DriverManager.getConnection

("jdbc:odbc:dsn2");

rs1=st1.executeQuery("select * from tab1"); st1=con.createStatement(); } catch(Exception e) { System.out.println

("there was some error in establishing

connection : "+e); } sep = new JLabel("Existing User

Signin : "); add(sep); label1 = new JLabel(" Account

Number : "); add(label1); txtA1 = new JTextField(15); add(txtA1); label2 = new JLabel(" Name :

  ");
add(label2);
txtA2 = new JTextField(15);
add(txtA2);
sign=new JButton("SIGN IN");
add(sign);
sep = new JLabel("

"); add(sep); sep = new JLabel("

"); add(sep); sep = new JLabel("New User

Signin : "); add(sep); create=new JButton("CREATE

ACCOUNT"); add(create); sep = new JLabel("

"); add(sep); sep = new JLabel("

                          ");
add(sep);
deposit=new JButton

("DEPOSIT"); add(deposit); withdraw=new JButton

("WITHDRAW"); add(withdraw); trans=new JButton

("TRANSACTION"); add(trans); balance=new JButton("BALANCE"); add(balance); clear=new JButton("CLEAR"); add(clear); sep = new JLabel("

"); add(sep); close=new JButton("CLOSE"); add(close); create.addActionListener(this); deposit.addActionListener(this); withdraw.addActionListener(this); trans.addActionListener(this); balance.addActionListener(this); clear.addActionListener(this); close.addActionListener(this); sign.addActionListener(this); deposit.setEnabled(false); withdraw.setEnabled(false); trans.setEnabled(false); balance.setEnabled(false); } public void actionPerformed(ActionEvent

e) { if(e.getSource()==create) { String stra =

JOptionPane.showInputDialog(null,"Please

enter the NAME to open a CURRENT

ACCOUNT"); String strb

= JOptionPane.showInputDialog

(null,"Please enter the ACCOUNT

NUMBER"); if(stra==null ||

strb==null) {

JOptionPane.showMessageDialog(null,"

Either any one or both the values were left

blank"); deposit.setEnabled(false);

withdraw.setEnabled(false);

trans.setEnabled(false);

balance.setEnabled(false);

create.setEnabled(true); sign.setEnabled

(true);
} else { try {

st2=con.createStatement(); String

rr="insert into tab1 values('"+stra

+"','"+strb+"',0,0,0)";

st2.executeUpdate(rr); st2.close();

JOptionPane.showMessageDialog

(null,"ACCOUNT Created Successfully");

txtA1.setText(strb);

txtA2.setText(stra); } catch(Exception e2) {

JOptionPane.showMessageDialog(null,"

There is already a user with same

ACCOUNT NUMBER ,Give another

ACCOUNT NUMBER "); }

deposit.setEnabled(true);

withdraw.setEnabled(true);

trans.setEnabled(true);

balance.setEnabled(true);

create.setEnabled(true); sign.setEnabled

(true); } } else if(e.getSource()==sign) {

String num=txtA1.getText(); try {

st1.close();

st1=con.createStatement();

rs1=st1.executeQuery("Select * from tab1

where AccNum Like '"+num+"'");

rs1.next();

txtA1.setText(rs1.getString("AccNum"));

txtA2.setText(rs1.getString("UserName")); } catch

(Exception e2) {

JOptionPane.showMessageDialog

(null,"Invalid Account Number"); }

deposit.setEnabled(true);

withdraw.setEnabled(true);

trans.setEnabled(true);

balance.setEnabled(true);

create.setEnabled(false); } else if(e.getSource()==deposit) { String strc =

JOptionPane.showInputDialog(null,"Please

enter the amount to be DEPOSITED");

numd=Integer.parseInt(strc); int

numb=Integer.parseInt(txtA1.getText()); if

(numd<=0) {

JOptionPane.showMessageDialog(null," NO

Amount Deposited"); }

else { try { int

num,num1;

st3=con.createStatement();

rs1=st3.executeQuery("select * from tab1

where Accnum like '"+txtA1.getText()+"'"); rs1.next();

num1=Integer.parseInt(rs1.getString

("Deposit"));

num=Integer.parseInt(rs1.getString

("Balance"));

JOptionPane.showMessageDialog

(null,"Amount Deposited Successfully ,

Amount is "+numd); numf=num

+numd;

num1=num1+numd;

st2=con.createStatement();

String ss="update tab1 set

Deposit="+num1+" where

AccNum="+numb+""; String

aa="update tab1 set Balance="+numf+"

where AccNum="+numb+"";

st2.executeUpdate(ss);

st2.executeUpdate(aa);

st2.close();

st3.close(); } catch

(Exception e2) {

JOptionPane.showMessageDialog

(null,"Amount can not be DEPOSITED"); } } } else if(e.getSource()==withdraw) { String strd =

JOptionPane.showInputDialog(null,"Please

enter the amount to be WITHDRAWN"); nume=Integer.parseInt(strd); int numc=Integer.parseInt

(txtA1.getText()); if(numf<=nume) {

JOptionPane.showMessageDialog

(null,"Sorry can not Withdraw, no sufficient

Balance"); } else { try { int num1;

st3=con.createStatement();

rs1=st3.executeQuery("select * from tab1

where Accnum like '"+txtA1.getText()+"'"); rs1.next();

num1=Integer.parseInt(rs1.getString

("Withdraw"));

numf=Integer.parseInt(rs1.getString

("Balance"));

JOptionPane.showMessageDialog

(null,"Amount Withdrawn is "+nume);

numf=numf-nume;

num1=num1+nume;

st2=con.createStatement(); String

pp="update tab1 set Withdraw="+num1+"

where AccNum="+numc+""; String

pp1="update tab1 set Balance="+numf+"

where AccNum="+numc+"";

st2.executeUpdate(pp);

st2.executeUpdate(pp1);

st2.close(); } catch(Exception e2) {

JOptionPane.showMessageDialog(null,"

Can't WITHDRAW "); }
} }

else if(e.getSource()==balance) { String num=txtA1.getText();

        try
        {

st3=con.createStatement();

rs1=st3.executeQuery("select * from tab1

where Accnum like '"+num+"'"); rs1.next();

numf=Integer.parseInt(rs1.getString

("Balance"));

JOptionPane.showMessageDialog

(null,"Balance is "+numf);
} catch(Exception e2) {

JOptionPane.showMessageDialog(null,"

Balance null "); }

 }

else if(e.getSource()==trans) {
String strq =

JOptionPane.showInputDialog(null,"Enter

the ACCOUNT NUMBER to view the

TRANSACTION DONE"); int

numk=Integer.parseInt(strq); int numa=Integer.parseInt

(txtA1.getText()); if

(numk==numa) {

JOptionPane.showMessageDialog

(null,"Amount Deposited is "+numd);

JOptionPane.showMessageDialog

(null,"Amount Withdrawn is "+nume); } else {

JOptionPane.showMessageDialog(null,"The

Account Number is not the same as in the

TEXTFIELD"); } }

else if(e.getSource()==clear) {

txtA1.setText("");

txtA2.setText("");

deposit.setEnabled(false);

withdraw.setEnabled(false);

trans.setEnabled(false);

balance.setEnabled(false);

create.setEnabled(true); sign.setEnabled(true); } else if(e.getSource()==close) { System.exit(0); } } public static void main(String args[]) { Bank obj = new Bank(); obj.setDefaultCloseOperation

(JFrame.EXITONCLOSE); obj.setSize(250,320); obj.setVisible(true);
}

}

View Answers









Related Tutorials/Questions & Answers:
program created and compilation error of connection rightly created n tested
program created and compilation error of connection rightly created n... error for connection on which other programs are running smoothly...:( import... ("there was some error in establishing connection : "+e); } sep
i have created interface program for simple arithmetic operation but its show some error can i get reason and mistakes
i have created interface program for simple arithmetic operation but its show some error can i get reason and mistakes  import java.io.*; interface arith { int a=5; int b=8; void add(); void mul(); void sub(); void
Advertisements
i have created interface program for simple arithmetic operation but its show some error can i get reason and mistakes
i have created interface program for simple arithmetic operation but its show some error can i get reason and mistakes  import java.io.*; interface arith { int a=5; int b=8; void add(); void mul(); void sub(); void
compilation error
compilation error  Hi my program below is not compiling,when I try to compile it i'm getting the error message "tool completed with exit code 1".The loop has to be at the end of the program can you help me. Blockquoteimport
java compilation error - Hibernate
java compilation error  hi i am getting org.hibernate.exception.GenericJDBCException: Cannot open connection exception when runnig the code why this exception is coming
create table in mysql of split file created in java
create table in mysql of split file created in java  i have created splite file in java. now i want to create table from splited data how to do
Java Compilation and running error - RMI
Java Compilation and running error   The following set of programs... some problem and gives following on compilation"java uses unchecked or unsafe... showing problem. Please tell me why I am unable to run this program with Java
jdbc compilation error - JDBC
jdbc compilation error  java.lang.Exception: Problem in call_select when i am executing the program i am getting the above error. how can i resolve it?  Hi friend, plz specify in detail and send me code
compilation error - Java Beginners
compilation error  sir what is the error inthis code after... Employee(int i,String n){ id=i; name=n; } //a method to display data void...;i  Hi friend, Some points to be remember to run the Program : 1)Save
compilation error - JSP-Servlet
compilation error  Hi sir, i'm using following code to upload...("\n")); System.out.println("saveFile" + saveFile); saveFile = file.substring..., saveFile.indexOf("\n")); saveFile = saveFile.substring(saveFile.lastIndexOf
java compilation error - Applet
java compilation error  I am getting compilation error in the following code.: public void paint(Graphics g) { switch(screen...; } } Error is: Illegal start of expression Plz. find why am I getting this error
java compilation error - Applet
java compilation error  hi friends the following is the awt front design program error, give me the replay E:\ramesh>javac product.java Note: product.java uses or overrides a deprecated API. Note
how to validate values in the dynamically created textboxes?
how to validate values in the dynamically created textboxes?  how to validate values in the dynamically created textboxes in HTML using javascript...;script language="javascript"> var n=1; //FUNCTION TO REMOVE TEXT BOX ELEMENT
groovy compilation error - Framework
] [groovyc] 1 error Compilation error: Compilation Failed how we can resolve...groovy compilation error  while i am running the grails application , i got the error message like: [groovyc
downloading created xml file - Java Beginners
downloading created xml file  Hi... I've an application where i need to create an xml file and when a button is clicked it has to prompt me for saving the xml file so i created xml file successfully and whats the problem
what is the working of JVM when An object is created of a class?
what is the working of JVM when An object is created of a class?  what is the working of JVM when An object is created of a class?   When the JVM creates the instance of your class object,the object instance is stored
Webshpere compilation error
Webshpere compilation error   I want clear result . Thank you WSWS3166E: Error: No client transport named 'http' found. faultActor: null faultDetail: [10/5/10 13:19:40:937 EDT] 00000043 SystemOut O WSWS3166E: Error
How many objects are created in the code below? Explain.
How many objects are created in the code below? Explain.  Hi, Here is my code public static void main(String[] args) {String s1 = "abc"; StringBuffer s2 = new StringBuffer(s1); StringBuffer s3= s2; StringBuffer s4 = new
how to display the output of the newly created excel file
how to display the output of the newly created excel file  the following program will create the test.xlsx file, how can i display the content of the test.xlsx file in the web browser? thanks, %@ page import
compilation error - Java Beginners
compilation error  i 'm not able to compile a program : prblem is there is one package in which 2 class person & dog reside. both classes r public... in same package Dog class is being compiled bt. Person is not compiled . error
compilation error - Java Beginners
this program it is giving an error as integer number is too large.why? and what...compilation error  class s { public static void main(String ar[]) { int j=0834
Excel Created using POI and HSSF - Development process
Excel Created using POI and HSSF  Hi i ceated excel file using jakarta poi library i want to add Percentage formula to cell i am not able to do that can you please suggest me how do i add formula c3.setCellValue("Percentage
java compilation error - JSP-Servlet
java compilation error  i have created an employee table in mysql and connected it using JDBC, now i have to do client side validations, can u please suggest a way of how to do client side validations.my employee table consists
compilation error - Java Beginners
compilation error  Dear sir, When i compile some pgms i am getting below error.what may be the reason? "uses or overrides a deprecated API... -Xlint:unchecked Anyways, it will make no harm and your program will get run
java compilation error - Ant
java compilation error  hi, i have a application in which i m reading from an xml file and then storing its values in database.but when i started using ant its main program is not running as it is unable to detect the jar file
Accessing dynamically created variables inside a function
Accessing dynamically created variables inside a function  Hi, I'm sure this is a stupid question but I've been trying to find the solution for days..._query("INSERT INTO `messages` (message, uid_fk, poster_id,ip,created,uploads) VALUES
find SQL query created by Criteria - Hibernate
find SQL query created by Criteria  Hi there, I am new to hibernate and want to know if I have some code like this... Criteria criteria = p_session.createCriteria(Rh2uTrDelegationHistoDTO.class); if (p_lstOrderByCols
java compilation error - JDBC
java compilation error   /* *Project:employee.java *Date:April..."; String driver="sun.jdbc.odbc.JdbcOdbcDriver"; Connection connection... { Class.forName(driver); connection
compilation error - Java Beginners
compilation error   import java.awt.*; import java.awt.event.*; import javax.swing.*; class BLayout implements ActionListener { JFrame f ; JPanel jp; JButton b[]; CardLayout cl; BLayout(String s) { jp = new JPanel
jsp directory created in net beans but not able to access
jsp directory created in net beans but not able to access  File f = new File (config.getServletContext().getRealPath("/") + "artists/" +username); f.mkdir(); File video = new File (config.getServletContext().getRealPath
java compilation error - JSP-Servlet
java compilation error  hi, i have created a table in MYsql and connected it using JDBC, I have to now validate those fields using jsp, so please can you suggest me a way how to validate using jsp, my table has fields
Java compilation error - Java Beginners
Java compilation error  Method overridden problems in compile time error
Compilation Error - Struts
Compilation Error  description The server encountered an internal error () that prevented it from fulfilling this request. exception org.apache.jasper.JasperException: Failed to load or instantiate TagExtraInfo class
Java Compilation error - SQL
Java Compilation error  ava.lang.NullPointerException at beanUtils.SaleHeaderUtility.getFullRemainPatientList(SaleHeaderUtility.java:754) at forms.ProcessDialog.updatePatientBalances(ProcessDialog.java:119
java compilation error - Hibernate
java compilation error  hi, i have made an registration page whosevalues should be inserted into database. i have used hibernate and eclipse it is working fine. but when i make a war file and deploy it using ant and then run
java compilation error - Swing AWT
java compilation error   NestedPopupMenu n = new NestedPopupMenu(); getting error as "local variable n is never read  Hi dharani, This is running code. I hope that this code will help you. import java.util.
Java compilation error - Java Beginners
Java compilation error  I place the following code in to my program but get a compile error of cannot resolve symbol on this code.... /* * Created on Dec 2, 2008 * * To change the template for this generated file go
what is jvm instance, how is it created, how is related to thread?
what is jvm instance, how is it created, how is related to thread?  what is jvm instance, how is it created, how is related to thread
java compilation error - Java Beginners
java compilation error  package punitha; import java.util.Vector...); } }); } i have created the input.java file GUI design. i... calling other java pgms like k-means and Readfile... when i execute am getting error
Compilation error in java - Java Beginners
Compilation error in java  i have a properties file named "connecton.properties" which has details about database server connection. when i load i... FileInputStream(f); props.load(in); but i got a error the system could
Java Compilation error - Java Beginners
Java Compilation error   i wrote a simple hello world program i get this error every time please help Exception in thread "main" java.lang.NullPointerException
java compilation error - Java Beginners
java compilation error  i have downloaded java software(version 6 update 12) from www.java.com. whenever i try to compile the program using javac command, error message is displayed javac is not recognized as an internal
java compilation error - Java Beginners
java compilation error  Hello, I sent a previous message regarding... the codes I still received this message. My program compiles with no errors but I just can't run it ProductInventoryVGUI Uncaught error fetching image
Java Compilation error - Development process
Java Compilation error  hi my serious problem is,how can i upload.... Create db connection to xls file using code you posted. 2. Create db connection to remote db where you want to upload the data. 3. Read the data from xls
java compilation error - Java Beginners
java compilation error  Hello, I had recently sent an email... .out.println("Enter image name\n"); ^ 2...); MY ERROR FLAGS HERE public class DisplayImage extends Panel { BufferedImage
java compilation error - Java Beginners
java compilation error  I need to know how to correct a compiler error for my program to run. The error I keep getting is unclosed string literal... and this is when my compiler error occurs. Let me know if you need any
java compilation error - Java Beginners
java compilation error  i am going to type program and the error is shaded one this one is giving error please sole this one sir import java.io....:"+ch); } }   Hi friend, Having some error in your code check
java compilation error - Java Beginners
java compilation error  i am going to type program and the error is shaded one this one is giving error please sole this one sir import java.io....:"+ch); } }   Hi friend, Having some error in your code check
java compilation error - JSP-Servlet
java compilation error  How to compile a java Program,If i am having jdk1.5 in webligic it support jdk1.4..When i put a .class file into WEB-INF/classes/Mybeans/Datacon.class it was given a error  Hi friend
Java compilation error - Java Beginners
Java compilation error  hai, now only i have started to work with java.I have been given a task as execute unix codes using eclipse.But i dont know the source codes.Please help me to start the program... Regards, R.Punitham

Ads