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

 
 


placid
urgent help needed in JDBC AND JAVA GUI
2 Answer(s)      3 years and 7 months ago
Posted in : JDBC

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 Pages:
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
Help needed for Form Validation please help!
Help needed for Form Validation please help!  I have created a page...;%@ page language="java" session="true" %> <% //Getting the text...("org.gjt.mm.mysql.Driver"); con = DriverManager.getConnection("jdbc:mysql://127.0.0.1/test
plz help me to create gui using Java netbeans
plz help me to create gui using Java netbeans  Hi, I am unable to fetch a particular data from DB.I am using netbeans for creating GUI. If I want.... I am unable to fetch the particular data. Plz help me   Hi Friend
servlet not working properly ...pls help me out....its really urgent
servlet not working properly ...pls help me out....its really urgent  ... con = DriverManager.getConnection("jdbc:mysql://localhost:3306/drona","root... servlet to radio buttons f jsp is correct or not <%@page language="java
reply me its urgent - Java Beginners
application in this type please help me i am using database mysql5.0 version... = Drivermanager.getConnection("jdbc:mysql://localhost:3306/student","root","root"); Invalid... urgent.  hi friend, i think password is wrong or username may be wrong
Help on JSP and JDBC - JDBC
Help on JSP and JDBC  Retrieve data from Database in JSP and JDBC...;% Connection con = null; String url = "jdbc:mysql://localhost:3306/"... do this, we are java programmers keep mind
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
. Its very urgent and important.......plz ,,,,,,,,help me
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
JDBC
JDBC save a data in the database  I need a code to save a data in the database can anyone help?   The given code set up the connection between java and mysql using JDBC and saves the data into the database. import
JDBC
JDBC code to save a data in the database  I need a code to save a data in the database can anyone help?   The given code set up the connection between java and mysql using JDBC and saves the data into the database
jdbc
stored procedure? exmp   ResultSet: ResultSet is a java object... logical group of data with a number of columns. JDBC ResultSet Example Stored... traffic and improve performance. Stored procedures can be used to help ensure
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
jdbc - JDBC
drivers for concurrent access?   Question: Is the JDBC-ODBC Bridge multi-threaded? Answer: No. The JDBC-ODBC Bridge does not support concurrent access from different threads. The JDBC-ODBC Bridge uses synchronized methods
jdbc - JDBC
."); Connection conn = null; String url = "jdbc:mysql://localhost:3306... many errors in it? Please help me out.  Hi friend, Plz specify... on Netbeans and jdbc visit to : http://www.roseindia.net/jdbc/ http
jdbc - JDBC
of columns even the developer don't know how many columns,(using java script new text... in JSP to create a table. 2)how desc can be written in JDBC concepts  Hi friend, Code to help in solving the problem : import java.sql.
jdbc - JDBC
and retrive it using a java program? plz help me with the code.  Hi...: http://www.roseindia.net/jdbc/save_image.shtml Retrieve Image using Java... = DriverManager.getConnection( "jdbc:mysql://localhost:3306/test", "root", "root
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
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
urgent need in two days - JSP-Servlet
understand the Mysql and Jdbc database connectivity code  understand the Mysql and Jdbc database connectivity code through example.  See... con = null; String url = "jdbc:mysql://localhost:3306/"; String
java jdbc
java jdbc  hi friends, I am not getting how to connect by using type 2 And type 3 drivers between java and oracle...... please any body help me...... thanking you, your's, praveen
java - JDBC
java  hi... help me to retrieve the image from the database please help me  Hi Friend, Try the following code: import java.sql.... = DriverManager.getConnection( "jdbc:mysql://localhost:3306/test", "root", "root
Java - JDBC
Java  sir i want to make a login form in servlet with session and cookies in java(netBeans6.1). plz help me to sove my problem.i shall be thank full to u
Java - JDBC
Java  sir i want to make a login form in servlet with session and cookies in java(netBeans6.1)also with run time database(MS-Access). plz help me to sove my problem.i shall be thank full to u
java - JDBC
project  Hi friend, Code to help in solving the problem : import... conn = DriverManager.getConnection("jdbc:oracle:thin:@training:1521:Oracle
java - JDBC
) please help me with the code  Hi Friend, Try the following code... = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root"); Statement st
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
java  i am developing a project on hotel managemnet and i need ways to find the availability of room. i dont how to find the availabilty of room. please help me my id is rajnath1@rediffmail.com
java - JDBC
java  /********************************************************** * Program to create GUI for ATM Simulation
java - JDBC
java  How to insert and retrieve image from oracle database? PLZ,,,explain with an example code? help,me plz....  Hi friend... class Browse_java { static Connection con=null; public static void main
JDBC Tutorial, JDBC API Tutorials
Java Database Connectivity(JDBC) Tutorial This tutorial on JDBC explains you the concept to Java Database Connectivity with the help of articles, examples... to use JDBC API effectively to develop database driven applications in Java. You
java - JDBC
help me i want this code for my project and u helped me alot in my project 
JAVA - JDBC
in my project. plz.....help me in this aspect also. code: (send by u
java - JDBC
" on the web-browser . please help me ... it's very crucial one in my project
JDBC - Java Beginners
JDBC  How to connect to mysql database from an applets or GUI components (on J2SE) using Eclipse
jdbc
jdbc   how to write program to save data and retrieve data from the form in Java
JDBC
JDBC  how to set classpath for eclipse, java, where to copy jdbc connector
Jdbc
Jdbc  A java program with jdbc connectivity with insert,delete,update options for name,regno,mark1,mark2,total
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 help - Java Beginners
Java help  Was this code created by netbeans or any other tool?? I am...(); Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/register...").newInstance(); Connection con = DriverManager.getConnection("jdbc:mysql
jdbc
links: http://www.roseindia.net/jdbc/Jdbc-batch-update.shtml http://www.roseindia.net/tutorial/java/jdbc/batchupdateresultsetexample.html...jdbc define batch updates  define batch updates?exp   JDBC
JDBC Examples, JDBC Example code
JDBC or Java Database Connectivity is the set of API for accessing the database from Java program. JDBC allows the developers to access almost all the major.... In this section you will find many examples of JDBC
JDBC Training, Learn JDBC yourself
will help the programmers to learn JDBC skills necessary to build powerful... JDBC Connection Pooling Accessing Database using Java and JDBC Learn how... Tutorials JDBC (Java Database Connectivity) -Tutorials  JDBC
jdbc - JDBC
Java JDBC application  Database Application in Java JDBC
jdbc
of ms-access using java application i want to perform both operations of ms-access using jdbc connection   import java.sql.*; public class CreateTable... = DriverManager.getConnection("jdbc:odbc:student"); Class.forName
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
jdbc insert
jdbc insert  Hi , i want to insert a declared integer variable into a mysql table through jdbc. how to insert that. help me with query... thanks in advance   Here is a java code that connects to database and create
JDBC
retrieve the value from database into dropdown list using JDBC SQL 2005  How to retrieve the value from database into dropdown list using JDBC &...").newInstance(); String connectionURL = "jdbc:mysql://localhost:3306/test";; Connection