This is the employee form to add data to mysql database but I got error of NullPointerException, Is this write code please give me feedback as soon as possible

This is the employee form to add data to mysql database but I got error of NullPointerException, Is this write code please give me feedback as soon as possible

import java.awt.Container; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.sql.Connection; import java.sql.DriverManager; import java.sql.Statement; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JTextField;

/** * * @author Ankur Pachegaokar */ public class InsertData extends JFrame implements ActionListener { JLabel l1,l2,l3,l4; JTextField tf1,tf2,tf3,tf4; JButton b;

InsertData() 
{
    Container c=getContentPane();
    c.setLayout(new FlowLayout());

    l1=new JLabel("Emp_Id");
    tf1=new JTextField(20);

    l2=new JLabel("F_Name");
    tf2=new JTextField(20);

    l3=new JLabel("M_Name");
    tf3=new JTextField(20);

    l4=new JLabel("L_Name");
    tf4=new JTextField(20);

    b=new JButton("Insert");

    c.add(l1);
    c.add(tf1);
    c.add(l2);
    c.add(tf2);
    c.add(l3);
    c.add(tf3);
    c.add(l4);
    c.add(tf4);

    c.add(b);

    b.addActionListener(this);



    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

@Override
public void actionPerformed(ActionEvent ae)
{
    if("Insert".equals(ae.getActionCommand()))
    {
        int Emp_id=Integer.parseInt(tf1.getText());
        String F_name=tf2.getText();
        String M_name=tf3.getText();
        String L_name=tf4.getText();

        try
        {
          Class.forName(com.mysql.jdbc.Driver).newInstance();
          Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/employee_database","root","root");
          Statement st=con.createStatement();
          System.out.println("query======for insert >>");
          st.executeUpdate("INSERT INTO emp_data (Emp_id,F_name,M_name,L_name) VALUES ("+Emp_id+",'"+F_name+"','"+M_name+"','"+L_name+"')");
          System.out.println("Data Sucessfully inserted.......");

           //con.close();


        }
        catch(Exception e)
        {
            System.out.println(e);
        }
       /* System.out.println(Emp_id);
        System.out.println(F_name);
        System.out.println(M_name);
        System.out.println(L_name);*/


    }
}
public static void main(String args[]) throws Exception
{
    InsertData id=new InsertData();
    id.setTitle("Employee Info");
    id.setSize(400, 500);
    id.setVisible(true);




print("code sample");

}print("code sample");
View Answers









Related Tutorials/Questions & Answers:
hi see and give me reply as soon as possible
hi see and give me reply as soon as possible  Hi Friend, I got path,but it will again ask path error first i was gave index.jsp.It.../hello) is not available. JBoss Web/2.1.2.GA above error will displayed pls
pls give me answer ae soon as possible - Ajax
pls give me answer ae soon as possible  i m writing code of ajax technology ...but it is not working pls check it n give me response quickly... give me quick response!!! thanks & regards shashank gupta
Advertisements
Please help me to write a code for add contacts to groups in a website?
Please help me to write a code for add contacts to groups in a website?   Iam developing a site. In that site I need to write code for Groups... send a code for this? Please make it fast
please help me to give code - Java Beginners
please help me to give code  Write a function with a signature cheerlead(word) that prints a typical cheer as follows. The word robot: Gimme an R Gimme an O Gimme a B Gimme an O Gimme a T What did you give me? ROBOT
please help me to give code - Java Beginners
please help me to give code  Write a program that prints an n-level...!"); String str = buff.readLine(); int i=1; int j; while(i<=4){ for(j=1;j<=i;j++) System.out.print(str); i=i+1; System.out.println
please help me to give code - Java Beginners
please help me to give code  Write a program that uses loops...; k<=4; k++){ System.out.print(k+"|"); for (int i=1; i<=4; i++){ System.out.print(i); } System.out.println
please help me to give code - Java Beginners
please help me to give code  Write a function, sliding(word, num)that behaves as follows. It should print out each slice of the original word having length num, aligned vertically as shown below. A call to sliding(examples, 4
please help me to give code - Java Beginners
please help me to give code  Write a program that reads a file named famous.txt and prints out the line with the longest length. In the case of a tie, you may print out only one of them. For example in the file: Alan Turing
please help me to write a code for this program
please help me to write a code for this program   1 1 1 1 2 2 1 1 3 4 3 1 1 4 7 7 4 1
please help me to write a code for this program
please help me to write a code for this program   1 1 1 1 2 1 1 3 3 1 1 4 6 4 1
please let me get code how to insert a data to mysql using setter and getter method by using java
please let me get code how to insert a data to mysql using setter and getter method by using java  please let me get code how to insert a data to mysql using setter and getter method by using java pelease let me have the code
please let me get code how to insert a data to mysql using setter and getter method by using java
please let me get code how to insert a data to mysql using setter and getter method by using java  please let me get code how to insert a data to mysql using setter and getter method by using java pelease let me have the code
how to send email please give me details with code in jsp,servlet
how to send email please give me details with code in jsp,servlet  how to send email please give me details with code in jsp,servlet
I GOT ERROR FOR MY PROJECT
I GOT ERROR FOR MY PROJECT  Dear Friend/ RoseIndia Team, Firstly I would to thank u Guys help me so many time.. I got error on my little project when running at server. please correctly my error Guys... ERROR CODE: "LOGIN
Please give me the answer.
"int a=08 or 09" its giving compile time error why   "int a=08 or 09" its giving compile time error why ? can any one give me the answer of this please
Please give me the code for the below problem - Java Interview Questions
Please give me the code for the below problem  PROBLEM : SALES TAXES... applicable on all imported goods at a rate of 5%, with no exemptions. When I purchase items I receive a receipt which lists the name of all the items
Please give me coding for this..
Please give me coding for this..  Write an application that inputs one number consisting of five digits from the user.separates the number ibto its individual digits and prints the digits separated from one another by three
plz plz plz inform me as soon as possible
plz plz plz inform me as soon as possible  ``by using c programs how to type
i got illegal start of expression error , plese tell me the mistake where i did...
i got illegal start of expression error , plese tell me the mistake where i did...   import org.springframework.context.*; import java.util.*; public class MyListener implements ApplicationListener { public static void main
I want to update the multiple values of database depending on checkbox..? Please help me out..
I want to update the multiple values of database depending on checkbox..? Please help me out..   Hi .. I want to Update the multiple values.....? please answer if any one knows as soon as possible..? Thanks in Advance
please any one can help me to write a code for this question?
please any one can help me to write a code for this question?  1) Copy one file content to other? 2) Count the number of words in a file
how can i write this program ?please suggest me
how can i write this program ?please suggest me  Program to calculate the sum of two big numbers (the numbers can contain more than 1000 digits). Don't use any library classes or methods (BigInteger etc
please any one can help me to write a code for this question?
please any one can help me to write a code for this question?  Q 1) In a class first day 25 students are joined. After two days that total students will increased to 60. We can develop a program by using ArrayList concept
i want java code for this xml file...please show me..
i want java code for this xml file...please show me..   xbrli:shares xbrli:pure iso4217:INR
this is my javascript code and i am not understanding the mistake in this,please help me?
this is my javascript code and i am not understanding the mistake in this,please help me?  <html> <h2>Form Validation</h2>...; if((nn1.value==null)||(nn1.value=="")){ alert("Please Enter
i got an error while compile this program manually.
i got an error while compile this program manually.  import...,struts jar files and i got an error in saveErrors() error Heading cannot find..., ActionForm form, HttpServletRequest request
creating a feedback form - JSP-Servlet
for providing me the solution for the problem entitled "inserting the data from radio button into database". the code you gave is working absolutely fine. but now i am refining this problem as follows: i am creating a feedback form
to write a program to display the employee details..
the employee details.please send me the code .it's urgent.send me as soon as possible... the details in a new windowusing java swings...please help me as soon... me the code soon.....it is some what urgent for me......thank u.... madhuri
i want to create website,with manu with three level submenu on top side of page please send me code java
i want to create website,with manu with three level submenu on top side of page please send me code java   iam createing wibsite thats using eclipse andtomcat server,please help me to write menu with three level submenu
I need help on my Java code.... please please help me out!?
I need help on my Java code.... please please help me out!?  Well my... the anagram on screen or the output file! Please show me whats wrong. Thanks i need a part of the code thats fixed if possible! Heres is the code: import
Plz give me code for this question
Plz give me code for this question  Program to find depth of the file in a directory and list all files those are having more number of parent directories
please give me an idea to develop a program for this question?
please give me an idea to develop a program for this question?  How to enter a text or number from keyboard without using InputStreamReader method in java
How do i validate form using javascript and send data to database?
How do i validate form using javascript and send data to database?  I need a "JOIN US" form that can validate using javascript and be able to connect with and post data into a database. The details to be validated and posted
Give me the source code for this problem
Give me the source code for this problem  Ram likes skiing a lot... help to know the longest run possible with the given peaks. That altitude... map, a possible ski path would be 36-33-24(start at 36, end at 24). Of course
programming error
for the respective name" error i got is:SQL exception please give me the solution by providing the exact coding,as soon as possible...programming error  I got an error when i did the following program
error please send me the solution
error please send me the solution  HTTP Status 500 - type Exception report message description The server encountered an internal error... java.sql.SQLException: No suitable driver found for jdbc:mysql//localhost:3306/mysql
error please send me the solution
error please send me the solution  HTTP Status 500 - type Exception report message description The server encountered an internal error... java.sql.SQLException: No suitable driver found for jdbc:mysql//localhost:3306/mysql
please give me a java program for the following question
please give me a java program for the following question  Write...; In the previous code, we forget to add an icon to button. So we are sending the updated code. import java.awt.*; import javax.swing.*; import
Select Employee and display data from access database in a jtable
Select Employee and display data from access database in a jtable  I... will use JDBC to connect to the database. Please help me... server, and implement the needed data objects in a database server. The clients
please help me solve this problem when i am create database connection using servlecontext
please help me solve this problem when i am create database connection using servlecontext  hi... I have create a database connection using servletcontext . in this code when i login first time it will exceute sucessfully
ModuleNotFoundError: No module named 'give_me_code'
'give_me_code' How to remove the ModuleNotFoundError: No module named 'give_me_code' error? Thanks   Hi, In your python...ModuleNotFoundError: No module named 'give_me_code'  Hi, My Python
displaying data for a single column from Mysql database in the list box in php form
displaying data for a single column from Mysql database in the list box in php form  I have a form in php.want to display data from a single column in an listbox in php.thanks..   <?php $data = @mysql_query("select
hi, Everyone ,i'm learning jdbc, i got an nullpointerexception when execute this program.
hi, Everyone ,i'm learning jdbc, i got an nullpointerexception when execute this program.   ConnectionProvider.java import java.util.*; import java.io.*; import java.sql.*; class ConnectionProvider { static Properties prop
verify the code and give me the code with out errors
verify the code and give me the code with out errors   import... clear the errors and give me correct tutorial for my knowledge improving.pls anyone help me. E:\>java add java.lang.NullPointerException at add
how can i create a mysql database to connect to this code - JDBC
how can i create a mysql database to connect to this code  i need help creating a mysql database for this code. code is import java.awt....("Deposit"); text10=new JTextField(10); b1=new JButton("Add"); b2=new JButton
how can i create a mysql database to connect to this code - JDBC
how can i create a mysql database to connect to this code  i need help creating a mysql database for this code. code is import java.awt....("Deposit"); text10=new JTextField(10); b1=new JButton("Add"); b2=new JButton
hi.. please give me a java coding for the following question
hi.. please give me a java coding for the following question  Write a program that prompts the user to enter the number of students and each studentā??s name and score, and finally displays the name of the students
retrieve data from mysql database
retrieve data from mysql database  hi am not familiar in php.....even... selected value on combobox which is to be retrieve the relevant data from mysql database using php.... below my code is that.. <html> <head>
Please tell me how I can access a field (data type char) of resultset in a java class
Please tell me how I can access a field (data type char) of resultset in a java... databse. There is a field named empsex whose data type is char. I have created...("empsex")); as erroneous. There is no method like getChar() also. Please tell me
inserting data from radio buttons to database-ERROR - JSP-Servlet
it in the code. but still i am getting the error in the update query. please provide...inserting data from radio buttons to database-ERROR  hi, i have already changed the option field of table question. the code which you give me has

Ads