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



Home Answers Viewqa Java-Beginners java server side validations
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


pavan
java server side validations
1 Answer(s)      4 years and 11 months ago
Posted in : Java Beginners



Advertisement
View Answers

November 27, 2009 at 5:16 PM


Hi Friend,

we are providing you a simple swing application to validate for unique username using MySql database.

import javax.swing.*;
import java.awt.*;
import java.sql.*;
import java.awt.event.*;
class CreateAccount extends JFrame{
JTextField text1,text2,text3,text4,text5;
JPasswordField pass1;
JLabel label1,label2,label3,label4,label5,label6;
JPanel panel;
JButton button,button1;
CreateAccount() {
text1=new JTextField(15);
text2=new JTextField(15);
text3=new JTextField(15);
pass1=new JPasswordField(15);
text4=new JTextField(15);
text5=new JTextField(15);
label1=new JLabel("First Name");
label2=new JLabel("Last Name");
label3=new JLabel("User Name");
label4=new JLabel("Password");
label5=new JLabel("Address");
label6=new JLabel("Phone No");
button=new JButton("Save");
panel=new JPanel(new GridLayout(7,2));
panel.add(label1);
panel.add(text1);
panel.add(label2);
panel.add(text2);
panel.add(label3);
panel.add(text3);
panel.add(label4);
panel.add(pass1);
panel.add(label5);
panel.add(text4);
panel.add(label6);
panel.add(text5);
panel.add(button);
panel.add(button1);
button.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae){
String value1=text1.getText();
String value2=text2.getText();
String value3=text3.getText();
String value4=pass1.getText();
String value5=text4.getText();
String value6=text5.getText();

Connection con = null;
String url = "jdbc:mysql://localhost:3306/";;
String db = "test";
String driver = "com.mysql.jdbc.Driver";
String user = "root";
String pass = "root";
String user1="";
String pass1="";
try{
Class.forName(driver);
con = DriverManager.getConnection(url+db, user, pass);
Statement st = con.createStatement();
ResultSet rs=st.executeQuery("Select * from login where username='"+value3+"'");
String usern="";
if(rs.next()){
usern=rs.getString("username");
JOptionPane.showMessageDialog(null,"Invalid UserName");
}
else {

int k=st.executeUpdate("insert into login(firstname,lastname,username,password,address,contactno) values('"+value1+"','"+value2+"','"+value3+"','"+value4+"','"+value5+"','"+value6+"')");
JOptionPane.showMessageDialog(null,"Data is successfully saved");
}

}
catch(Exception e){}
}
});
add(panel);
setSize(300,400);
setVisible(true);
}
public static void main(String[]args){
CreateAccount acc=new CreateAccount();
}


}
Hope that it will be helpful for you.
Thanks


Related Tutorials/Questions & Answers:
java server side validations - Java Beginners
java server side validations  how to write the server side validation for unique username in java? please help me   Hi Friend, we are providing you a simple swing application to validate for unique username using
server side scripting java - JSP-Servlet
server side scripting java  I Very new to java server pages I am doing a project in java messaging service so in that i have a client on d server... on the server side i want that in the client side as pop up window
Advertisements
server side scripting in php
server side scripting in php  is it possible to access values on server side in post request PHP
Hi i want java code that diaplays server scren at the client side
Hi i want java code that diaplays server scren at the client side  Hi I'm Shivaprasad i want java socket code that shows the server side screen when client gets connected with the server. Please help me   Please visit
java validations
java validations  <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01...; if (f.length<20) { alert("Address too short"); return false; } var q=document.retailer.contact_no.value; if (q==null || q=="") { alert
server-side inclusions in xml
server-side inclusions in xml  Hi... Can I still use server-side inclusions in xml? please tell me about that ASAP Thanks
validations
validations  How to get All Client and server side validations in spring using jsp   Please visit the following link: Spring Validation Example
Difficulty using javascript in server side - Java Interview Questions
Difficulty using javascript in server side   why interaction with server using javascript is difficult
session variables server side
session variables server side  how to hold session variable for server side..?   request.getSession().setAttribute("wellSelection", uid
Server side validation vs client side validation
Server side validation vs client side validation  Can any one tell me... of Server side validation vs client side validation.   The client side validation runs in the browser where as server side validation runs on server
how to perform the client side validations to the dropdown list using javascript?
how to perform the client side validations to the dropdown list using javascript?  Hi Good Morning! This is Prasad, I want to perform the client side validation to the dropdown list using javascript. So give me sample.I am
Server side Paging in jsp ?
Server side Paging in jsp ?  Hi i am student of It . i am learning jsp-servlet and i am trying to do paging in my report generation but i want to do server side paging and i am using oracle 10g in back end . it will be very
server side validation in struts
server side validation in struts  Hello sir, i want to do server side validation in struts based on 3 fields. those 3 field are BatchNo,LotNo,StepNo.Here we can have the same batchno,lotno for different forms
Client Side and Server Side coding
Client Side and Server Side coding       The combo of client side and server side coding... to write code in both client side and server side. Some other combinations are &ndash
What do you think about client-side/server-side coding ?
What do you think about client-side/server-side coding ?  Hi, What do you think about client-side/server-side coding
Server Side Coding
Server Side Coding       Server Side Coding, on the other hand is the script that does...-side script cannot run and it will also not support the client-side script. Server
which server side script used in j2ee - Ajax
which server side script used in j2ee  Which server-side script... scenario you have to call the server side script? Thanks... to, and processes the data.  Hi, You can use ajax in JavaScript to talk to server
Struts Validations - Framework
Struts Validations  What is the server-side validations exactly? give me on example
reading a file on server side - JSP-Servlet
reading a file on server side  Thank you sir for replying with the solution of my first question. Now i am facing some problem in renameing & reading a word file in JSP which is uploaded by client. please help me
EasyEclipse Server Java
EasyEclipse Server Java       EasyEclipse Server Java For development of server-side... servers (Tomcat, JBoss, WebLogic), develop on some server-side frameworks (Struts
Server Side Application
Server Side Application       Server side application is used to get the message.... The Server side application follows these steps Firstly creates a new server socket
how a write a server side progranming in j2sdk for j2me application
how a write a server side progranming in j2sdk for j2me application  ... Server type. so,i want to ask you, 1)How i am establish Msoffice Database connectivity. 2)How do i write a server side(servlet)program in j2me
Introduction to Server Side Programming
Introduction to Server Side Programming   .... Why Server Side Programming? Though it is technically... is ? ?Server Side Programming?. Figure-1 illustrates Server side architecture
validations in javascript
validations in javascript  How do you check validations in javascript
Server side Validation
Server Side Validation It is very important to validate the data coming from the client side, so that wrong data could not process into the application...(); } } After that write a xml file for server side validation. The naming
Spring Validations
Spring Validations  Hi.. i need code for validations using spring annotations
validations - Struts
validations  log in page with validations user name must be special character and one number and remining is alphabetes in struts
Server side validation on dynamically generated fields from more than one table on spring framework.
Server side validation on dynamically generated fields from more than one table on spring framework.   Server side validation on dynamically generated fields from more than one table in spring mvc framework
Custom Validations - Struts
Custom Validations  Hi, I am trying to do the custom validations in struts 1.1.That is how can we plug in our own custom validations.../tutorialsearch/?t=server%20side%20validations%20using%20struts1.2 Thanks
Advertisements
 

 

 

DMCA.com