Home Answers Viewqa Java-Beginners abt java project

 
 


sunil kumar pandey
abt java project
1 Answer(s)      3 years and 3 months ago
Posted in : Java Beginners

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 Pages:
abt java project - Java Beginners
abt java project  if we want to create a pannel on the button how to write on the code in side the button plz help
abt java project - Java Beginners
abt 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
abt java project - Java Beginners
abt 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 Beginners
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
abt proj - Java Beginners
abt 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 Beginners
abt 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 Beginners
abt 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 Beginners
abt 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 Questions
abt 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
need to ans abt db - JSP-Servlet
need 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
absolutely no idea abt a program - Java Beginners
absolutely no idea abt a program  write a program in java/blue...(" "); System.out.print(arr[j]); } } } For more information on java visit to : http://www.roseindia.net/java Thanks
project
project  i need a project in java backend sql
project
project  suggest a network security project based on core java with explanation
project
project  sir i want a java major project in railway reservation plz help me and give a project source code with entire validation thank you
Project
Project  How to show Questions randomly so that no two student get the same questions in online examination system project in Java Server Pages my email id is moiza_sayyed@rediffmail.com
project
project   hi , we r working on one project related to our results. we using java and for back end sqlserver 2005. In dis we are trying to retrieve result from some site and store it in our data base so that we can perform
Project
Project  Hi, Am starting a new project to draw a 2d graph using java swing and opengl,where in the input for X-axis and Y-axis co=ordinates should be accepted from user... As am very new to this am seeking help so pls help
project...
project...   enter 10 integers, store it using array then display them from highest to lowest. 2.enter 10 integers, store it using array then display them from lowest to highest number to words conversion create a java program
project
project  write a program in java to develop a port scanner for common devices(HTTP,FTP,Telnet
project
project  how to make blinking eyes using arc, applet in core java
project
should write Java code, so as to: 1. Compute Gross Monthly Salary for all employees
java project
java project  how many tables are required in backend for online examination system project in jsp If backend is SQL
java project
java 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
abt the bank application
abt 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
JAVA project
JAVA project  How to extract tags and their corresponding properties of a "cascading style sheet" file using JAVA
java project
java project  Connecting to MySQL database and retrieving and displaying data in JSP page by using netbeans
project enquire
project enquire  **hi admin, are you had project about "project tracking" on java
project - Java Beginners
project in Java  Need example project in Java
Project Doubght
Project Doubght  What is meant by server monitoring in java enterprise application
project query
project query  I am doing project in java using eclipse..My project is a web related one.In this how to set sms alert using Jsp code. pls help me
Regarding Project
Regarding Project  sir, i am doing a project in java. my project is CITY GUIDE it is an web application. please give me documentation of my project
Regarding Project
Regarding Project  sir, i am doing a project in java. my project is CITY GUIDE it is an web application. please give me documentation of my project
Project in jsp
Project in jsp  Hi, I'm doing MCA n have to do a project 'Attendance Consolidation' in JSP.I know basic java, but new to jsp. Is there any JSP source code available for reference...? pls help me
java project - Java Beginners
java project  how can i download the source code for the project college admission system
Java Project - Java Beginners
Java 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
CoreJava Project
CoreJava Project  Hi Sir, I need a simple project(using core Java, Swings, JDBC) on core Java... If you have please send to my account
project detail - Java Beginners
project detail  Dear roseindia, i wnat to the idea for doing project in the java
Java Project - Java Beginners
Java 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
want a project
want a project  i want to make project in java on railway reservation using applets and servlets and ms access as database..please provide me code and how i can compile and run
java project - Java Beginners
java 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 Beginners
Java 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 Beginners
JAVA 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
project detail - Java Beginners
project 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
MINI PROJECT
MINI PROJECT  CAN ANYONE POST A MINI PROJECT IN JAVA?   Hi... You can have the following projects as per ur requirement. Free and easy to download.. All projects are JAVA based Sale and purchase in java swing Java
need project
need project  hi im new on this site so dnt knw actual procedure . but i need a project on banking system in java with sql database. which should... is good plz add it i need project till Saturday i.e 10th march 2012 plzzzz
JAVA AWT BASE PROJECT
JAVA AWT BASE PROJECT  suggest meaningful java AWT-base project
Related to Project
Related to Project  how speech to text project can be make in java? Please tell me the coding part therapeutically i know i have to use java speech api which offer two technology 1. speech recognization 2. speech syenthesis
Java Project - Java Beginners
Java 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 Beginners
java 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
regarding project
JAVA PROGRAM?(JAVA/MVC/UI) BRIEF DESCRIPTION OF A PROJECT: The program helps...regarding project   sir we need help about project. we have idea about his project please guide me sir. OBJECTIVES OF THIS PROJECT: -Ability

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.