urgent help needed in JDBC AND JAVA GUI

urgent help needed in JDBC AND JAVA GUI

View Answers

November 27, 2009 at 11:30 AM

Hi Friend,

Try the following code:

import java.awt.*;
import java.sql.*;
import javax.swing.*;
import java.awt.event.*;

class createSAccount extends JFrame{
JTextField text1,text2,text3,text4,text5,text6,text7,text8,text10;
JLabel label1,label2,label3,label4,label5,label6,label7,label8,label9,label10,label;
JPasswordField text,text9;
JLabel lab1;
JPanel panel,panel1;
JButton b1,b2,b3,b4;
JTabbedPane tp;
createSAccount(){
JTabbedPane tp=new JTabbedPane();
panel=new JPanel(new GridLayout(10,2));
panel1=new JPanel(new GridLayout(3,2));
label1=new JLabel("Name");
text1=new JTextField(10);
label=new JLabel("Password");
text=new JPasswordField(10);
label2=new JLabel("Year of study");
text2=new JTextField(10);
label3=new JLabel("Faculty");
text3=new JTextField(10);
label4=new JLabel("Course");
text4=new JTextField(10);
label5=new JLabel("University");
text5=new JTextField(10);
label6=new JLabel("Phone No");
text6=new JTextField(10);
label7=new JLabel("Email Id");
text7=new JTextField(10);
label8=new JLabel("Address");
text8=new JTextField(10);
label9=new JLabel("Enter Password");
text9=new JPasswordField(10);
label10=new JLabel("Deposit");
text10=new JTextField(10);
b1=new JButton("Add");
b2=new JButton("Reset");
b3=new JButton("Savings");
b4=new JButton("Withdraw");
panel.add(label1);
panel.add(text1);
panel.add(label);
panel.add(text);
panel.add(label2);
panel.add(text2);
panel.add(label3);
panel.add(text3);
panel.add(label4);
panel.add(text4);
panel.add(label5);
panel.add(text5);
panel.add(label6);
panel.add(text6);
panel.add(label7);
panel.add(text7);
panel.add(label8);
panel.add(text8);
panel.add(b1);
panel.add(b2);
panel1.add(label9);
panel1.add(text9);
panel1.add(label10);
panel1.add(text10);
panel1.add(b3);
panel1.add(b4);

b1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae){
String t1=text1.getText();
String t=text.getText();
String t2=text2.getText();
String t3=text3.getText();
String t4=text4.getText();
String t5=text5.getText();
String t6=text6.getText();
String t7=text7.getText();
String t8=text8.getText();

try{
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/register";, "root", "root");
Statement st=con.createStatement();
int i=st.executeUpdate("insert into bankdata(name,pass,year,faculty,course,university,phoneNo,email,address) values('"+t1+"','"+t+"',"+t2+",'"+t3+"','"+t4+"','"+t5+"',"+t6+",'"+t7+"','"+t8+"')");
JOptionPane.showMessageDialog(null,"Thanks for creating an account.");
}
catch(Exception e){}
}
});
b2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae){
text1.setText("");
text.setText("");
text2.setText("");
text3.setText("");
text4.setText("");
text5.setText("");
text6.setText("");
text7.setText("");
text8.setText("");
}
});

November 27, 2009 at 11:31 AM

continue..........

b3.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae){
String t9=text9.getText();
String t10=text10.getText();
int savings=Integer.parseInt(t10);
int bal=0;
try{
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/register";, "root", "root");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("Select balance from bankdata where pass='"+t9+"'");

if(rs.next()){
bal=rs.getInt("balance");
int ts=savings+bal;
Statement st1=con.createStatement();
st1.executeUpdate("update bankdata set balance="+ts+" where pass='"+t9+"'");
JOptionPane.showMessageDialog(null,"Your savings is: "+ts);
}
}

catch(Exception e){}
}
});
b4.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae){
String t9=text9.getText();
int bal=0;
JOptionPane pane = new JOptionPane("Do you want to withdraw");
Object[] options = new String[] { "Yes", "No" };
pane.setOptions(options);
JDialog dialog = pane.createDialog(null, "Dilaog");
dialog.show();
Object obj = pane.getValue();
String st=obj.toString();
if(st.equals("Yes")){
String st1=JOptionPane.showInputDialog(null,"Enter amount to withdraw");
int withdrawl=Integer.parseInt(st1);
try{
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/register";, "root", "root");
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("Select balance from bankdata where pass='"+t9+"'");

if(rs.next()){
bal=rs.getInt("balance");
int leftSavings=bal-withdrawl;
Statement stat=con.createStatement();
stat.executeUpdate("update bankdata set balance="+leftSavings+" where pass='"+t9+"'");
JOptionPane.showMessageDialog(null," You have withdrawn "+withdrawl+" shillings and your balance is "+leftSavings);
}
}
catch(Exception e){}
}
else{
System.exit(0);
}
}
});
tp.addTab("Create Account",panel);
tp.addTab("Deposit/Withdraw",panel1);
add(tp);
setVisible(true);
pack();
}
public static void main(String[]args){

createSAccount acc=new createSAccount();
}
}

Thanks









Related Tutorials/Questions & Answers:
urgent help needed in JDBC AND JAVA GUI - JDBC
urgent help needed in JDBC AND JAVA GUI  my application allows... want any one to help me convert from scanner to java GUI for this code...(); } } // thanks for any help rendered   Hi Friend, Try the following code
java - JDBC
have to use JDBC and oracle. plz send the details for connecting "java...). It's very urgent,,,,,,plzzzzzzzzzzzzzzzzzz   Hi friend, I am sending data inserting code into database using JDBC with jsp
Advertisements
java - JDBC
available in that particular place in the same page.(by using Oracle and java(jdbc)).... please......It's very important and urgent....  Hi friend, I am sending a link. I hope that, this link will help you. Following
java - JDBC
java  How to connect java(jsp) and oracle8i? plz, explain every step included in the process. It's urgent..  Hi friend, Code to help... oracle.jdbc.driver.OracleDriver()); Connection conn = DriverManager.getConnection("jdbc
Java jdbc
Java jdbc  What is JDBC
Java JDBC
Java JDBC   Is the JDBC-ODBC Bridge multi-threaded
regarding java - JDBC
done front end work using swing and AWT concepts of java i am using mysql as back end and i have also configured java with mysql i am using three table... can to able to insert or update data entry in these tables through GUI which
Java - JDBC
Java and JDBC programming  Need to learn the kills to develop the application using java and jdbc
Java JDBC
Java JDBC  What is the fastest type of JDBC driver
Java JDBC
Java JDBC  How to make pagination using JDBC
java servlets jdbc - JDBC
java servlets jdbc  i am running the servlet program with jdbc connections in this porgram i used two 'esultset' objects.. in this wat ever coding is available in the first resultset is executed like updating and retrieiving
java - JDBC
java  hello, i have oracle 8i,i am a java-learner, i would like to run a jdbc programs. please tell me the steps how to run the jdbc program  For the complete reference and tutorial on Java Database Connectivity visit
JAVA(JDBC) - JDBC
JAVA(JDBC)  Hello friends, please tel me, how can we retrieve..."; String driverName = "com.mysql.jdbc.Driver"; String url = "jdbc:mysql... for more information. http://www.roseindia.net/jdbc/save_image.shtml
Java JDBC driver
Java JDBC driver  What is JDBC Driver
java - JDBC
java  how to get connectoin to database server from mysql through java programme  Hi Friend, Please visit the following link for more detailed information http://www.roseindia.net/jdbc/jdbc-mysql
Java JDBC
Java JDBC  Is JDBC-ODBC bridge multi-threaded?  NO. The JDBC-ODBC Bridge uses synchronized methods to serialize all of the calls made.... The JDBC-ODBC Bridge uses synchronized methods to serialize all of the calls
java programing - JDBC
java programing  A retail company has got the records of its... GUI application to provide facility to add, save, delete, find and navigate... procedure call). Use JDBC
Java jdbc class.forName error - JDBC
Java jdbc class.forName error  HI: how is possible that my JDBC connection to an MYSQL instance works inside the IDE (Netbeans) and not when I start it from the jar file? Could some please give some pointers please? Higly
java - JDBC
java  how can i connect jdbc with oracle 9i.please give detailed procedure.  Hi Friend, Use JDBC with Oracle Follow these steps: 1) Import the following packages in your java file:*********** import
java - JDBC
, The JDBC-ODBC Bridge uses synchronized methods to serialize all of the calls that it makes to ODBC. Multi-threaded Java programs may use the Bridge... is the traditional management layer of JDBC, working between the user
java jdbc
java jdbc  what is a prepared statement?   Hi Friend, It is a pre compiled form of Statement class. It send sql statements to the database... of its examples from the given link: JDBC Tutorials ThanksADS_TO_REPLACE_2
java - JDBC
java  please help to retrieve image from database when a search query is given from a text box in java code using oracle as a backend database ...").newInstance(); Connection con = DriverManager.getConnection("jdbc:mysql
java - JDBC
to implement singleton class in the below code.please help me out public..."; public static final String DB_URL="jdbc:mysql://localhost:3306/link_db... visit to : http://www.roseindia.net/java/beginners/SingletonPattern.shtml
java - JDBC
metadata  Hi friend, 1. First import the java packages... = "com.mysql.jdbc.Driver"; 3.Creating a jdbc Connection String url = "jdbc.... Creating a jdbc Statement object Statement st = conn.createStatement(); 5
Java Jdbc-odbc
Java Jdbc-odbc  What is the difference between JDBC and ODBC
Java JDBC ODBC
Java JDBC ODBC  What is the difference between JDBC and ODBC
Java Jdbc connection
Java Jdbc connection  What are the two major components of JDBC
Java JDBC driver
Java JDBC driver  What are the different JDBC drivers available
JAVA - JDBC
JAVA  how to store and retrieve an image in a database(ORACLE)using java or JSP?  Hi friend, I am sending you image insert code in jsp using mysql jdbc driver so please change driver name and implement
Java Jdbc
Java Jdbc  sir i want to databse(oracle 10g)connectivity through java through program   Hi Friend, Follow these steps: 1) Import the following packages in your java file: import java.sql.*; import
java - JDBC
java   how insert the row through ResultSet using the insertRow()method   Hi Friend, Try the following code: import java.sql.... con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root
java jdbc connecting probelm - JDBC
java jdbc connecting probelm  import javax.servlet.*; import javax.servlet.http.*; import javax.sql.*; import java.io.*; public class ECom...=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","scott","tiger
java - JDBC
java  how to access excel file through jdbc show record in table.... Click "Ok" and restart your compiler. 7. Compile the following java code...("sun.jdbc.odbc.JdbcOdbcDriver"); Connection conn=DriverManager.getConnection("jdbc:odbc:excel
java - JDBC
java  how to create a database for java with images in ms access(2007...{ String url="jdbc:odbc:access"; File file=new File("c:\\barbie.jpg...("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con = DriverManager.getConnection("jdbc:odbc
Mysql & java - JDBC
Mysql & java  Hi guys, please help! I'm new to mysql, I want to connect to mysql 5.1 using java. But it shows error about: Class.forName("com.Mysql.Jdbc.Driver").newInstance. Is there something I'm not doing right? Please help
Java Jdbc connection
Java Jdbc connection  What is the use of Class.forName
java - JDBC
java  java code for retrive an image from mysyl database through jFrame  Hi Friend, Try the following code: import java.sql.... con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root
java - JDBC
java  java code for retrive images from mysql database through jFrame  Hi Friend, Try the following code: import java.sql.*; import...("com.mysql.jdbc.Driver").newInstance(); Connection con = DriverManager.getConnection("jdbc
java - JDBC
; String url = "jdbc:mysql://192.168.10.211:3306/"; String db = "amar... -------------------------------------- Read for more information. http://www.roseindia.net/java/example/java/awt/ Thanks. Amardeep
Java jdbc connection
Java jdbc connection  Does the JDBC-ODBC Bridge support multiple concurrent open statements per connection
About java and JDBC
in GUI window using jdbc-odbc separate program i had written. Now what i want...About java and JDBC  Hello sir, I am doing project on java... created a name ,textfield ,calender(for DObirth selection), this is displayed in GUI
About java and JDBC
in GUI window using jdbc-odbc separate program i had written. Now what i want...About java and JDBC  Hello sir, I am doing project on java... created a name ,textfield ,calender(for DObirth selection), this is displayed in GUI
java cade - JDBC
java cade  I need an example on TYPE4 driver connecting with SQLServer2005 I already wrote the code like this code: // QueryApp2.java (JDBC... = DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:8080;DatabaseName
Java Jdbc connection
Java Jdbc connection  What are the steps involved for making a connection with a database or how do you connect to a database
Java code - JDBC
Java code  Write a Java Program Using JDBC that Runs On LAN and Enter the Student Infomation and Store them in the Database Crated on Server Computer
excel file using JDBC java.?
excel file using JDBC java.?  hey, i am a telecomm. engineer , and i... used JDBC ODBC to read from excel file. i am not able to append it using executeupdate query. can you help me do
java program - JDBC
java program  i have a DBschema, in that i have schema name and set of tables as fields, in this case i have three tables, i need a java program..., Please give details to solve the problem. For read JDBC connection
jdbc connection to java program code - JDBC
jdbc connection to java program code  i want a simple java program that which communicates with oracle database like creating table,insert values and update records in database and show in program output? please take a simple
java runtime error - JDBC
java runtime error  when i m running my jdbc program it is giving the problem as class not found exception.so, please suggest me what may... information on JDBC visit to : http://www.roseindia.net/jdbc/ Thanks
java programming - JDBC
java programming  Develop a simple OPAC system for library using even-driven and concurrent programming paradigms of Java. Use JDBC to connect to a back-end database.please reply immediately sir

Ads