Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JDBC urgent help needed in JDBC AND JAVA GUI
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


placid
urgent help needed in JDBC AND JAVA GUI
2 Answer(s)      5 years and a month ago
Posted in : JDBC



Advertisement
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
Java - JDBC
Java and JDBC programming  Need to learn the kills to develop the application using java and jdbc
Java JDBC
Java JDBC  How to make pagination using JDBC
Java JDBC
Java JDBC  What is the fastest type of JDBC driver
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
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 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) - 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
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 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... from the given link: JDBC Tutorials Thanks
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
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
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
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
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
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 driver
Java JDBC driver  What is JDBC Driver
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 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 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
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  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
 

 

 

DMCA.com