Home Answers Viewqa JDBC verify the code and give me the code with out errors

 
 


stalin
verify the code and give me the code with out errors
0 Answer(s)      5 months and 4 days ago
Posted in : JDBC

import java.awt.*;
import java.awt.event.*;
import javax.swing.border.Border;
import javax.swing.BorderFactory;
import javax.swing.*;
import java.awt.Dimension;
import javax.swing.JLabel;
import javax.swing.JComponent; 
import java.awt.Graphics;
import java.sql.*;
import javax.swing.JFrame;
import javax.swing.JPanel;
import java.util.Date;
public class add 
{
String msg;
JFrame f;
JPanel p;
JTextField l=new JTextField();

JLabel l1=new JLabel("REG.NO");
JTextField t=new JTextField(6);

JLabel l2=new JLabel("NAME");
JTextField t1=new JTextField(15);

JLabel l3=new JLabel("COLLEGE NAME");
JTextField t2=new JTextField(35);

JLabel l4=new JLabel("CONTACT NO");
JTextField t3=new JTextField(11);

JLabel l5=new JLabel("EMAIL-ID  ");
JTextField t4=new JTextField(20);

JLabel l6=new JLabel("PROJECT IN");
String project[]={"NETWORK","EMBEDDED","VLSI","HARDWARE","VB.NET","JAVA","ASP.NET","ECE"};

JLabel l7=new JLabel("COURSE");
String course[]={"EMBEDDED SYSTEM","VLSI DESIGN","PLC","PCB 

DESIGN","C/C++","JAVA","J2EE","VB.NET","ASP.NET","PHP","NETWORKING","WIRELESS"};

JLabel l8=new JLabel("PROJECT TITLE");
JTextArea title=new JTextArea(3,60);

JLabel l9=new JLabel("AMOUNT");
JTextField t5=new JTextField(7);
JLabel l10=new JLabel("PAID");
JTextField t6=new JTextField(7);

JLabel l11=new JLabel("BALANCE");
JTextField t7=new JTextField(7);

JLabel l12=new JLabel("ADDRESS");
JTextArea address=new JTextArea(4,40);

JButton save=new JButton("SAVE");
JButton clear=new JButton("CLEAR");
JButton print=new JButton("PRINT");


JComboBox c4=new JComboBox(project);
JComboBox c5=new JComboBox(course);

public add()
{
f=new JFrame("ADD NEW STUDENT");
p=new JPanel();
p.setLayout(new GridLayout(0, 3));
l.setText("DATE:"+""+new Date().toString());
l.setForeground(Color.RED);
Border border=BorderFactory.createLineBorder(Color.BLUE,3);
l.setBorder(border);
p.add(l);
p.add(l1);
p.add(t);

p.add(l2);
p.add(t1);
p.add(l3);
p.add(t2);
p.add(l4);
p.add(t3);
p.add(l5);
p.add(t4);
p.add(l6);
p.add(c4);
p.add(l7);

p.add(c5);
p.add(l8);
p.add(title);
p.add(l9);
p.add(t5);
p.add(l10);
p.add(t6);
p.add(l11);
p.add(t7);
p.add(l12);
p.add(address);

p.add(save);
p.add(clear);
p.add(print);

clear.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
t.setText("");
t1.setText("");
t2.setText("");
t3.setText("");
t4.setText("");
t5.setText("");
t6.setText("");
t7.setText("");
address.setText("");
title.setText("");
}
});
save.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
try
{
String date=l.getText();
double regno=Double.parseDouble(t.getText());
String name=t1.getText();
String college=t2.getText();
double contactno=Double.parseDouble(t3.getText());
String email=t4.getText();
String project=c4.getSelectedItem().toString();
String course=c5.getSelectedItem().toString();
String Title=title.getText();
double amount=Double.parseDouble(t5.getText());
double paid=Double.parseDouble(t6.getText());
double balance=Double.parseDouble(t7.getText());
String Address=address.getText();
Connection con=null;

Statement st=con.createStatement();
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:student");
int query=st.executeUpdate("INSERT INTO student" 

+"(date,regno,name,college,contactno,email,Project,course,Title,amount,paid,balance,Address)"+"VALUES(?,?,?,?,?,?

,?,?,?,?,?,?,?)");

JOptionPane.showMessageDialog(null, "Succesfully 

Saved.","Information",JOptionPane.INFORMATION_MESSAGE);
}
catch(Exception eex)
{
eex.printStackTrace();
}
}
});

f.add(p, BorderLayout.CENTER);
f.add(p);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  f.setSize(800,800);

 f.setVisible(true);

}

public static void main(String[] args)
{
add a=new add();
}
}

when i run this program... it shows the given below errors.pls clear the errors and give me correct tutorial for my knowledge improving.pls anyone help me.

E:\>java add
java.lang.NullPointerException
    at add$2.actionPerformed(add.java:143)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1
95)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.ja
a:2318)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonMode
.java:387)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:24
)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButton
istener.java:236)
    at java.awt.Component.processMouseEvent(Component.java:6263)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
    at java.awt.Component.processEvent(Component.java:6028)
    at java.awt.Container.processEvent(Container.java:2041)
    at java.awt.Component.dispatchEventImpl(Component.java:4630)
    at java.awt.Container.dispatchEventImpl(Container.java:2099)
    at java.awt.Component.dispatchEvent(Component.java:4460)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:457
)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238

    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
    at java.awt.Container.dispatchEventImpl(Container.java:2085)
    at java.awt.Window.dispatchEventImpl(Window.java:2478)
    at java.awt.Component.dispatchEvent(Component.java:4460)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThr
ad.java:269)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread
java:184)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThr
ad.java:174)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169

    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161

    at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
View Answers









Related Pages:
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
code to alert when no checkbox is selected and verify them with orther set
code to alert when no checkbox is selected and verify them with orther set ... in database Thanks a lot in advance guys Please help me out guys please.. i...".. Now i need a code to throw alert whenc there is no check box selected under
errors
) { Win32OperatingSystem.Shutdown(@"Machinename", @"UserName", @"Pwd"); } plz hlp me that what the errors in above code
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 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
Give me the source code for this problem
Give me the source code for this problem  Ram likes skiing a lot. That's not very surprising, since skiing is really great. The problem with skiing is one have to slide downwards to gain speed. Also when reached the bottom most
Please give me the code for the below problem - Java Interview Questions
Please give me the code for the below problem  PROBLEM : SALES TAXES... 0.05) amount of sales tax. Write an application that prints out the receipt... Vidya  Hi Friend, Try the following code: import java.util.
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 stair case made of text. The user should choose the text character and the number of stairs in the stair case * ** *** ****   Hi friend
please help me to give code - Java Beginners
please help me to give code  Write a program that uses loops to generate an n x n times table. The program should get n from the user. As a model here is a 4 x4 version: | 1 2 3 4
Commenting out your code - Java Tutorials
errors But the given below code compile : public class Sample2...Commenting Erroneous Code & Unicode newline Correct In this section, you will find an interesting  problem related to commenting erroneous code
Compiler errors in java
Compiler errors in java  Hi, I used GenerateRDF java file. Am getting errors when i run this code. I used command prompt only. getting errors as no package exist. i followed your instructions properly. Please help me out
code
code  please provide code for custom tags.by using currdate tag we need to get current date?please give me 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
give me source code of webpage creation using html
give me source code of webpage creation using html  how to create a webpage using html
give me a grid example in php
give me a grid example in php  give me easy code example of grid in php like mysql editor
Pleae help me to give logic and code for this program - Java Beginners
Pleae help me to give logic and code for this program  Write a function that given the string ?original? create a new string ?dramatic? that has two consecutive copies of each letter from the original string. For example
Java Swing code for zoom in and out
Java Swing code for zoom in and out  hi.......... I require a code in java swing for image zoom in and zoom out can u tell me how it can be done or what is the code plz help
Javascript coding for link a website to another upon verify the form - Java Beginners
Javascript coding for link a website to another upon verify the form  Pls tell me javascript coding for " open a website when we click the verify...; Hi friend, Code to solve the problem : New Document
give the code for servlets session
give the code for servlets session  k give the code of total sample examples of servlet session
Getting 404 errors - Java Beginners
=UTF-8"); PrintWriter out = response.getWriter(); String... I received a 404 errors and I identified that the servlet doesn't appear... not sure and I'm hoping you experts will advise me. I have only done something
huffman code give the explanation for this code
huffman code give the explanation for this code  package bitcompress...); } value = 0; bit_count = 0; } } else { int code; bit_array[bit_count++] = bit; if ((code = huffcode_find (bit_array
huffman code give the explanation for this code
huffman code give the explanation for this code  package bitcompress...); } value = 0; bit_count = 0; } } else { int code; bit_array[bit_count++] = bit; if ((code = huffcode_find (bit_array
give the code for this ques///
give the code for this ques///  write a program in java in which there is a clss readline. the functionality of this class is to read a string from... the following code: import java.util.*; class ReadLine{ public static String
give information or website address
help me out...give information or website address  hi i want u r help .... i m finding code for constructing graph in java but during execting them i have
give the code for this ques///
give the code for this ques///  write a program in java which contains a class simple. this class contains 4 members variables namely a,b,c,and d...//   Hi Friend, Try the following code: class Simple{ int a,b,c,d
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
What is the errors?
What is the errors?  ) while ( c <= 5 ) { product *= c; ++c;   if ( gender == 1 ) cout << "Woman" << endl; else; cout << "Man" << endl;   Post the whole code
code
and give him Rs 300/- as education allowance for each children. Write a single line of code to print the amount he should be paid as allowance
compilation errors
; response.setContentType("text/html"); PrintWriter out = response.getWriter...() { } } giving errors: 1) WelcomeServlet.java:37: ')' expected..."+"</a>"); ^ please tell me the reason. fast
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
Index Out of Bound Exception
Index Out of Bound Exception       Index Out of Bound Exception  are the Unchecked Exception that occurs at run-time errors. This arises because of  invalid parameter
Show me the code for that
Show me the code for that  JVM on my machine? And how do I know whether its working
code - Java Beginners
a program for deleting the files from recycle bin can you give me that code ... actually i written code like this.. but run time error is coming.. import java.io.... System.out.println("Cannot delete: " + f); } } } please verify
Help please, some strange errors
play the error hits on to the console view. Can someone tell me what in the code is causing that run-time errors? Any kind of help will be helpful to me. and let.... As a beginner in java i got no idea which part of the code is creating
Html Code - Development process
Html Code  Hi,Can u give me code for Html . headers are Date, Name and Dept . Inside Date column i want to split 2 columns. like In and Out. I have tried colspan tag , but i couldnt get d output. Thank u in advance 
source code
source code  hellow!i am developing a web portal in which i need to set dialy,weekly,monthly reminers so please give me source code in jsp
java code
java code  need java code for chart or graph which compare the performance of aprior algorithm and coherent rule algorithm.plz any one help me out
scrollRectToVisible code
scrollRectToVisible code  HI, Give me some of scrollRectToVisible to move to a particular view. Thanks
code required
page Will you plz help me out by providing me with the code...code required  I am making a blog in java using netbeans and database connectivity with SQL Server 2008. I am using JSP pages for the same
Error in a code. - Java Beginners
quite figure out how to write the code for the GUI. Could anyone please help...Error in a code.  This is the question I posted yesterday: "I'm... figure out the whole process of figuring out if the number is prime or not and also
Unreachable code
at line: 50 in the jsp file: /refreshPage.jsp Unreachable code 47...() for servlet jsp threw exception Following is my code: refreshPage.jsp...; <tr bgcolor="gray"> <td><c:out
ajax and jsp code - Ajax
ajax and jsp code  can u please give me the code for retriving... +"'"; PrintWriter out = res.getWriter(); String result=""; try... +"'"; PrintWriter out = res.getWriter(); String result=""; try
C# code
C# code  hi pls clear my doubts this is my code but out is not well through this code i need display a particular row to a particular columns pls help me thank you, protected void Button3_Click(object sender, EventArgs e
Ajax Code Libraries and Tools
it will even give you some ideas! If you come up with something special please let me... Ajax Code Libraries and Tools        Code libraries and loots for the development of your Ajax
plz help me out with this problem...please write the program for me.thanxxxxx
plz help me out with this problem...please write the program for me.thanxxxxx  Write a program that will print out a hydro bill. The bill... will be entered by the user: - Account number (12 digit code) - Address - Kilowatts used
plz help me out with this problem...please write the program for me.thanxxxxx
plz help me out with this problem...please write the program for me.thanxxxxx  Write a program that will print out a hydro bill. The bill... will be entered by the user: - Account number (12 digit code) - Address - Kilowatts used
provide me code - Java Beginners
provide me code  can any body provide code for SNAKE XENZIA game in NOKIA mobile? please urgently

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.