abt java project
this program compile sucessfully but data is not store in data base if any thing correction plz do it
import java.awt.*;
import javax.swing.*;
import java.sql.*;
import java.awt.event.*;
public class simple extends JFrame implements ActionListener{
private static final long serialVersionUID = 1L;
JLabel label1,label2,label3;
JTextField textfield1,textfield2;
JPasswordField pass;
JButton button1,button2;
JPanel panel;
public simple()
{
label1=new JLabel("user Name");
textfield1=new JTextField(15);
label2=new JLabel("Password");
pass=new JPasswordField(15);
label3=new JLabel("address");
textfield2=new JTextField(15);
button1=new JButton("SAVE");
button2=new JButton("cancel");
panel=new JPanel(new GridLayout(15,2));
panel.add(label1);
panel.add(textfield1);
panel.add(label2);
panel.add(pass);
panel.add(label3);
panel.add(textfield2);
panel.add(button1);
panel.add(button2);
button1.addActionListener(this);
button1.setActionCommand("SAVE");
//button1.addActionListener(new ActionListener());
add(panel);
setSize(300,400);
setVisible(true);
}
public void actionPerformed(ActionEvent ae) {
String cmd=ae.getActionCommand();
if (cmd.equalsIgnoreCase("SAVE")){
String value1=textfield1.getText();
String value2=textfield2.getText();
String value3=pass.getText();
Connection con=null;
Statement stm=null;
String user1="";
try
{
Class.forName("org.postgresql.Driver");
con = DriverManager.getConnection("jdbc:postgresql://localhost" + "/smp", "postgres", "postgres");
stm=con.createStatement();
ResultSet res=stm.executeQuery("select *from register where username="+value1+"");
System.out.print("query executed");
if(res.next())
{
user1=res.getString("username");
JOptionPane.showMessageDialog(null,"invalid userName");
}
else
{
stm.execute("insert into register values('" +value1+ "','" +value2+ "','"+value3+"')");
JOptionPane.showMessageDialog(null, "Data successfully saved");
}
}
catch(Exception e)
{
}
}
}
public static void main(String arg[])
{
simple smp=new simple();
}
}
View Answers
February 15, 2010 at 1:42 PM
Hi Friend,
Try the following code:
import java.awt.*;
import javax.swing.*;
import java.sql.*;
import java.awt.event.*;
public class simple extends JFrame implements ActionListener{
JLabel label1,label2,label3;
JTextField textfield1,textfield2;
JPasswordField pass;
JButton button1,button2;
JPanel panel;
public simple(){
label1=new JLabel("user Name");
textfield1=new JTextField(15);
label2=new JLabel("Password");
pass=new JPasswordField(15);
label3=new JLabel("address");
textfield2=new JTextField(15);
button1=new JButton("SAVE");
button2=new JButton("cancel");
panel=new JPanel(new GridLayout(15,2));
panel.add(label1);
panel.add(textfield1);
panel.add(label2);
panel.add(pass);
panel.add(label3);
panel.add(textfield2);
panel.add(button1);
panel.add(button2);
button1.addActionListener(this);
button1.setActionCommand("SAVE");
add(panel);
setSize(300,400);
setVisible(true);
}
public void actionPerformed(ActionEvent ae) {
String cmd=ae.getActionCommand();
if (cmd.equalsIgnoreCase("SAVE")){
String value1=textfield1.getText();
String value2=textfield2.getText();
String value3=pass.getText();
System.out.println(value1+" "+value2+" "+value3);
Connection con=null;
Statement stm=null;
String user1="";
try{
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:
mysql://localhost:3306/test";, "root", "root");
stm=con.createStatement();
int i=stm.executeUpdate("insert into login(username,password,address) values('"+value1+"','"+value3+ "','"+value2+"')");
JOptionPane.showMessageDialog(null, "Data successfully saved");
}
catch(Exception e)
{
}
}
}
public static void main(String arg[])
{
simple smp=new simple();
}
}
Thanks
Related Tutorials/Questions & Answers:
abt java project - Java Beginnersabt java project I don't know too much about
java , and I am working on
java project, where editor is eclipse and backend postgresql
How can i take help about my
project, which book I should refers plz help me
Advertisements
abt java project - Java Beginnersabt java project How to make the home page that contain four tabbedPane like additem, deleteitem ,update etc,
so plz help me
thanx Hi.../
java/example/
java/swing/add_edit_and_delete_employee_inf.shtml
If you want
abt java project - Java Beginnersabt java project this program compile sucessfully but data is not store in data base if any thing correction plz do it
import java.awt.*;
import javax.swing.*;
import java.sql.*;
import java.awt.event.*;
public class
abt proj - Java Beginnersabt proj which topic i have to study carefully ,when I am going to start
java project using swings Hi Friend,
Learn awt, swing...
http://www.roseindia.net/
java/example/
java/awt/
http://www.roseindia.net
abt proj - Java Beginnersabt proj if we have already make login page and resister page, if i click on the login button we go to the home page ,home page contain some data
plz help
abt java - Java Beginnersabt java hiiiii
i m new to this language
i have some problem with my
java code ... i working on netbeans ..
i write a code for user authetication ... in this code it take user name password and a user certificate(which
abt proj - Java Beginnersabt proj I made login page, when i click on login button , thaen how to go on home page on home page containe some tab like add, delete, update,etc... the following link:
http://www.roseindia.net/
java/example/
java/swing/add_edit_and_delete
abt jmeter - Java Server Faces Questionsabt jmeter how to use jmeter for testing the program?
Hi friend,
For using jmeter for testing visit to :
http://www.roseindia.net/jmeter/
http://www.roseindia.net/jmeter/using-jmeter.shtml
Thanks
ModuleNotFoundError: No module named 'abt'ModuleNotFoundError: No module named '
abt' Hi,
My Python program is throwing following error:
ModuleNotFoundError: No module named '
abt'
How to remove the ModuleNotFoundError: No module named '
abt' error
abt the bank applicationabt the bank application pls can u send to me the user table and transaction table sql statement with their datatype used in this bank application to my email
need to ans abt db - JSP-Servletneed to ans
abt db helllo can you tell me
m just starting to knowing
abt servlet and i trying to making e-mail site so can you tell me with the
java servlet wht is the backhand database to use to proper with that site
Java ProjectJava Project
Java project using with collection and generic with observer design pattern
java projectjava project how many tables are required in backend for online examination system
project in jsp
If backend is SQL
java projectjava project i would like to get an idea of how to do a
project by doing a
project(hospital management) in java.so could you please provide me with tips,UML,source code,or links of already completed
project with documentation
JAVA projectJAVA project How to extract tags and their corresponding properties of a "cascading style sheet" file using
JAVA java projectjava project Connecting to MySQL database and retrieving and displaying data in JSP page by using netbeans
Java ProjectJava Project how to write a program for competitive exams(for student practice purpose)?
for example: first student have to login after login then he has to select the particular exam what he want to write i.e the exam may
Java Project - Java BeginnersJava Project Hello Sir I want Mini Student Admission System
project in
java
with Source Code and Back end Database is MS Access.
plz Give That Sir its Very Very Urgent
Java Project - Java BeginnersJava Project Dear Sir,
Right now i am working in
java image processing
project.
In that i have to split in one image like Texture, color...,
Please visit the following links:
http://www.roseindia.net/
java/example
Java Project - Java BeginnersJava Project Hey, thanks for everything your doing to make us better. Am trying to work on a
project in
java am in my first year doing software Engineering and the
project is m end of year
project. Am really believing
Java Project - Java BeginnersJava Project I'm a III yr Engineering student. I've been ask 2 prepare a
project on
Java. Can u plz suggest me some topics ? Hi friend...
Java project topic with more information.
1. Asset Management
2. Shopping
java project - Java Beginnersjava project
project for internet banking Hi friend,
I am sending you a link. This link will help you.
Please visit for more information.
http://www.roseindia.net/jsp/bank.shtml
Thanks
JAVA PROJECT - Java BeginnersJAVA PROJECT Dear Sir,
I going to do
project in
java " IT in HR, recruitment, Leave management, Appriasal, Payroll"
Kindly guide me about... etc. I am doing
project first time.
waiting for your reply,
Prashant
java project - Java Beginnersjava project hi this amol
i wish to do a
project on banking software in
java
can u help
how can i help u .. and what the kind... adam
certified
java programmer
certified websphere ya sure!!
what
java project - Java Beginnersjava project Can u pls suggest me any ideas for my B.E
project?
It's urgent...
Front end---
Java
Back end----Oracle
IDE---------Netbeans5.5
It should not be completely database oriented...
I am not allowed to develop any
Java Project - Java BeginnersJava Project Write a
Java program to create simple Calculator for 4 basic Math operations, Addition, Subtraction, Multiplication and Division... the following link:
http://www.roseindia.net/
java/example/
java/swing/calculator
Java Project - Java BeginnersJava Project Dear Sir,
I have to do
Project in "IT in HR i.e. Recruitment, Leave Management, Appraisal & payroll. These are Four main modules... employee master.
Now, can you tell in
Java programming with Mysql How can
java project - Java Beginnersjava project HAVE START A J2ME
PROJECT WITH NO CLEAR IDEA .. ANY ONE...
project titled, as ?M-News Application? is basically a mobile news application
Project. In our
project we are going to develop a Mobile Application which
JAVA Project - Java BeginnersJAVA Project Hi Friends,
Can somebody please tell me a website from where I can download
java live projects along with the source code
Java Project - Java Beginners question in my
java project.
But this program is shoing error on the 50th line...
Java Project Create a class Computer that stores information about...;
public Computer(String n,int s,int sp,String m,double p,int
q){
name=n;
size=s
project detail - Java Beginnersproject detail How to do
project in
java
I am doing final MCA i want to do
project
I am willing to do
project in
java or j2ee. But I have no idea so I want some idea about
project in
java
please give some sample
project java project - JavaMailjava project i want to make a
project in
java on ethernet mailing system.....can you provide the source code of this?and give me more suggestions to make
java project questionjava project question how to calculate bill extracting quantity n price from one database table and inserting the result into another in
java
Hi Friend,
Visit Here
Thanks