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



Home Answers Viewqa JDBC 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

Have Programming Question? Ask it here!
 
 
 


Ankur Pachegaokar
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
0 Answer(s)      11 months ago
Posted in : JDBC


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");

Advertisement
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
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 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 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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
i have got error while compiling simple tag handler
i have got error while compiling simple tag handler   javac.servlet.jsp not found! tell me what are the jar files required to run simple tag handler...;it is : javax.servlet.jsp only but getting error wt is reason
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
Add Employee
Add Employee  coding for adding an employee
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
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
plz plz rply as soon as possible
plz plz rply as soon as possible  by using c programs * * * * * s s s s s * s s o s s s s s s s s s s s s s s s s s s s s s s s
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
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
How do I write a program to manage an employee's business and personal contacts?
How do I write a program to manage an employee's business and personal contacts... as persistent data in a database. Include a prompt that allows the user to enter... of displaying the menu screen until the user has selected ‚??quit.‚?? ‚?Ę add
Employee form
Employee form  In employee form emp Id id after any data iserted is incremented for oher data insertion. insert, delete, update buttons when we cleak the select buttoun then the created table data iserted automaticaly
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
when I run exiting project that time I got error, I want solution on it?
when I run exiting project that time I got error, I want solution on it?  Error occurred during deployment: Exception while loading the app.../apache/commons/lang3/StringUtils. Please see server.log for more details
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 displays the following table (note that 1 mile is 1.609 kilometers). Miles Kilometers
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
retrive the employee details with image from mysql database using jsp servlet
retrive the employee details with image from mysql database using jsp servlet  im doing the web project to retrive the employee profile which i stored in the database using jsp servlet then want to show the result in the next jsp
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
nullpointerException
nullpointerException  sir i create the on login module in that mysql generate the nullpointerException? please send login mdule code in jsp and servlet using mvc model?   Please visit the following link: Jsp Servlet
 

 

 

DMCA.com