473,653 Members | 2,955 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

getting err java.lang.NullP ointerException

2 New Member
i dont know y im getting this err java.lang.NullP ointerException

if u find out something here is my mail id <deleted>

Expand|Select|Wrap|Line Numbers
  1. package login;
  2.  
  3. import java.awt.EventQueue;
  4. import java.swing.*;
  5. import javax.swing.*;
  6. import java.awt.BorderLayout;
  7. import java.awt.GridBagLayout;
  8. import java.awt.event.ActionListener;
  9. import java.awt.event.ActionEvent;
  10. import java.sql.*;
  11.  
  12. public class Remake extends JFrame {
  13.  
  14.  
  15.  
  16.  
  17.     private JFrame frame;
  18.     private JTextField txtfname;
  19.     private JTextField txtadd;
  20.     private JTextField txtemail;
  21.     private JTextField txtuser;
  22.     private JTextField txtlname;
  23.     private JPasswordField txtpass;
  24.     private JTextField txtphone;
  25.     private JComboBox cmbgender;
  26.  
  27.     /**
  28.      * Launch the application.
  29.      */
  30.     public static void main(String[] args) {
  31.         EventQueue.invokeLater(new Runnable() {
  32.             public void run() {
  33.                 try {
  34.                     Remake window = new Remake();
  35.                     window.frame.setVisible(true);
  36.                 } catch (Exception e) {
  37.                     e.printStackTrace();
  38.                 }
  39.             }
  40.         });
  41.     }
  42.  
  43.     /**
  44.      * Create the application.
  45.      */
  46.     public Remake() {
  47.         initialize();
  48.     }
  49.  
  50.     /**
  51.      * Initialize the contents of the frame.
  52.      */
  53.     private void initialize() {
  54.         frame = new JFrame();
  55.         frame.setBounds(100, 100, 743, 460);
  56.         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  57.         frame.getContentPane().setLayout(null);
  58.  
  59.         JLabel lblNewLabel = new JLabel("pd");
  60.         lblNewLabel.setBounds(226, 34, 258, 54);
  61.         frame.getContentPane().add(lblNewLabel);
  62.  
  63.         JLabel lblNewLabel_1 = new JLabel("First name");
  64.         lblNewLabel_1.setBounds(76, 112, 46, 14);
  65.         frame.getContentPane().add(lblNewLabel_1);
  66.  
  67.         JLabel lblNewLabel_2 = new JLabel("addr");
  68.         lblNewLabel_2.setBounds(76, 162, 46, 14);
  69.         frame.getContentPane().add(lblNewLabel_2);
  70.  
  71.         JLabel lblNewLabel_3 = new JLabel("email");
  72.         lblNewLabel_3.setBounds(76, 222, 46, 14);
  73.         frame.getContentPane().add(lblNewLabel_3);
  74.  
  75.         JLabel lblNewLabel_4 = new JLabel("username");
  76.         lblNewLabel_4.setBounds(76, 278, 46, 14);
  77.         frame.getContentPane().add(lblNewLabel_4);
  78.  
  79.         JLabel lblNewLabel_5 = new JLabel("last name");
  80.         lblNewLabel_5.setBounds(448, 112, 46, 14);
  81.         frame.getContentPane().add(lblNewLabel_5);
  82.  
  83.         JLabel lblNewLabel_6 = new JLabel("gender");
  84.         lblNewLabel_6.setBounds(448, 162, 46, 14);
  85.         frame.getContentPane().add(lblNewLabel_6);
  86.  
  87.         JLabel lblNewLabel_7 = new JLabel("phone");
  88.         lblNewLabel_7.setBounds(448, 222, 46, 14);
  89.         frame.getContentPane().add(lblNewLabel_7);
  90.  
  91.         JLabel lblNewLabel_8 = new JLabel("passwrd");
  92.         lblNewLabel_8.setBounds(448, 278, 46, 14);
  93.         frame.getContentPane().add(lblNewLabel_8);
  94.  
  95.         JButton btnNewButton = new JButton("New button");
  96.         btnNewButton.addActionListener(new ActionListener() {
  97.             public void actionPerformed(ActionEvent e) {
  98.  
  99.                 try {
  100.  
  101.                     String query="INSERT INTO `redu`(`fname`, `lname`, `addr`, `gender`, `email`, `phone`, `username`, `password`) VALUES (?,?,?,?,?,?,?,?)";
  102.                     Connection con= DriverManager.getConnection("jdbc:mysql://localhost:3306/remake","root","");
  103.                     PreparedStatement pst=con.prepareStatement(query);
  104.  
  105.                     pst.setString(1, txtfname.getText());
  106.                     pst.setString(2, txtlname.getText());
  107.                     pst.setString(3, txtadd.getText());
  108.                     pst.setString(4, cmbgender.getSelectedItem().toString());
  109.                     pst.setString(5, txtemail.getText());
  110.                     pst.setString(6, txtphone.getText());
  111.                     pst.setString(7, txtuser.getText());
  112.                     pst.setString(8, txtpass.getText());
  113.                     pst.executeUpdate();
  114.  
  115.                     JOptionPane.showMessageDialog(null, "register successfully");
  116.                 }
  117.                 catch(Exception ex){
  118.                     System.out.println(ex);
  119.                 }
  120.  
  121.  
  122.  
  123.  
  124.             }
  125.         });
  126.         btnNewButton.setBounds(326, 338, 89, 23);
  127.         frame.getContentPane().add(btnNewButton);
  128.  
  129.         txtfname = new JTextField();
  130.         txtfname.setBounds(208, 109, 86, 20);
  131.         frame.getContentPane().add(txtfname);
  132.         txtfname.setColumns(10);
  133.  
  134.         txtadd = new JTextField();
  135.         txtadd.setBounds(208, 159, 86, 20);
  136.         frame.getContentPane().add(txtadd);
  137.         txtadd.setColumns(10);
  138.  
  139.         txtemail = new JTextField();
  140.         txtemail.setBounds(208, 219, 86, 20);
  141.         frame.getContentPane().add(txtemail);
  142.         txtemail.setColumns(10);
  143.  
  144.         txtuser = new JTextField();
  145.         txtuser.setBounds(208, 275, 86, 20);
  146.         frame.getContentPane().add(txtuser);
  147.         txtuser.setColumns(10);
  148.  
  149.         txtlname = new JTextField();
  150.         txtlname.setBounds(564, 109, 86, 20);
  151.         frame.getContentPane().add(txtlname);
  152.         txtlname.setColumns(10);
  153.  
  154.         txtpass = new JPasswordField();
  155.         txtpass.setBounds(564, 275, 86, 20);
  156.         frame.getContentPane().add(txtpass);
  157.  
  158.         txtphone = new JTextField();
  159.         txtphone.setBounds(564, 219, 86, 20);
  160.         frame.getContentPane().add(txtphone);
  161.         txtphone.setColumns(10);
  162.  
  163.         JComboBox cmbgender = new JComboBox();
  164.         cmbgender.setModel(new DefaultComboBoxModel(new String[] {"1", "2", "3"}));
  165.         cmbgender.setBounds(564, 158, 86, 22);
  166.         frame.getContentPane().add(cmbgender);
  167.     }
  168.  
  169. }
May 13 '21 #1
1 2958
Banfa
9,065 Recognized Expert Moderator Expert
If you are getting a java.lang.NullP ointerException then you should be getting an entire stack trace giving you near enough the line of code that is going wrong. Please post that stack trace.
May 18 '21 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
3579
sammyboy78
by: sammyboy78 | last post by:
Hello again, This time I'm creating a program that creates an array of CD objects and then displays the information. I've created a CD class, a CDInventory class and then a CDInventoryDisplay to use the previos two. I've gotten all of this code oto compile but I'm still doing something wrong. I'm about to pull my hair out! When I run my CDInventoryDisplay program it comes back with this error: C:\Documents and Settings\Sam>java...
0
1568
by: gezkk | last post by:
hi, i m using http proxy service to get proxy and host to applet, its working fine with jdk1.5 but getting java.lang.NullPointerException in jdk1.6 And the following is mseeage contains java console java.lang.NullPointerException at com.atonesoftware.web.applet.transfer.client.http.HTTPTransfer.autoDetectProxy(HTTPTransfer.java:326)
18
2570
by: pradeep84 | last post by:
hi all, i'm using the following code and i'm getting exception in thread "main" java.lang.nullpointerexception at the line which is in bold. help me to solve this problem import java.applet.*; import java.awt.*; import java.io.*; import javax.swing.*; import java.sql.*;
1
2410
by: ksrashmi | last post by:
HI I am getting following exception when i use mxml tags in jsp <%@ taglib uri="FlexTagLib" prefix="mm" %> can any one tell why i am getting this exception type Exception report message description The server encountered an internal error () that prevented it from fulfilling this request.
3
7648
by: ohadr | last post by:
hi, i get Exception in thread "main" java.lang.NullPointerException when i run my application. the exact error is: "Exception in thread "main" java.lang.NullPointerException at sortmergejoin.MergeJoin.Field(MergeJoin.java:204) at sortmergejoin.MergeJoin.SMJoin(MergeJoin.java:84) at sortmergejoin.MergeJoin.<init>(MergeJoin.java:34) at sortmergejoin.Main.main(Main.java:24) Java Result: 1"
1
6750
by: onlinegear | last post by:
HI i am writing this for college i know i have loads of combo boxes with nothing in the i havent got that far yet. but every time i run this is comes up with this erro run: Exception in thread "main" java.lang.NullPointerException at java.awt.Container.addImpl(Container.java:1041) at java.awt.Container.add(Container.java:365) at orderingsystem.OrderingSystem.<init>(OrderingSystem.java:261) at...
3
4276
by: makweatan | last post by:
Hello guys... Data is not updated into table. I got this error : java.lang.NullPointerException 00000030 SystemErr R java.lang.NullPointerException 00000030 SystemErr R at my.org.hasil.dcms.grq.dao.XC18DAO.updateXC18(XC18DAO.java) 00000030 SystemErr R at my.org.hasil.dcms.grq.bo.XC18BO.processXC18(XC18BO.java) 00000030 SystemErr R at my.org.hasil.dcms.grq.web.XC18Action.performSedia(XC18Action.java) The program...
0
8283
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8704
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8470
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8590
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7302
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6160
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4291
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1914
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1591
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.