Results 1 to 2 of 2
Thread: hi help needed, this is urgent
- 02-07-2009, 09:19 AM #1
Member
- Join Date
- Feb 2009
- Posts
- 1
- Rep Power
- 0
hi help needed, this is urgent
Hi i get this error when running my app
Exception in thread "main" java.lang.NullPointerException
here is the sample code
package matthewproj;
import org.jdesktop.application.Action;
import org.jdesktop.application.ResourceMap;
import org.jdesktop.application.SingleFrameApplication;
import org.jdesktop.application.FrameView;
import org.jdesktop.application.TaskMonitor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Timer;
import javax.swing.Icon;
import javax.swing.JDialog;
import javax.swing.JFrame;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jdesktop.application.Action;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.PreparedStatement;
import static java.lang.System.in;
import java.util.Scanner;
import java.sql.*;
import java.sql.*;
/**
*
* @author Matthew
*/
public class JProgrammer extends javax.swing.JFrame {
private static final String DRIVER = "sun.jdbc.odbc.JdbcOdbcDriver";
private static final String URL =
"jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=H:\\Java Projectz\\SoftwareCo.mdb;}";
/** Creates new form JProggrammer */
public JProgrammer() {
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jSeparator1 = new javax.swing.JSeparator();
jLabel2 = new javax.swing.JLabel();
jTextField1 = new javax.swing.JTextField();
jLabel3 = new javax.swing.JLabel();
jTextField2 = new javax.swing.JTextField();
jLabel4 = new javax.swing.JLabel();
jTextField3 = new javax.swing.JTextField();
jLabel5 = new javax.swing.JLabel();
jTextField4 = new javax.swing.JTextField();
jLabel6 = new javax.swing.JLabel();
jTextField5 = new javax.swing.JTextField();
jLabel7 = new javax.swing.JLabel();
jTextField6 = new javax.swing.JTextField();
jLabel8 = new javax.swing.JLabel();
jTextField7 = new javax.swing.JTextField();
jLabel9 = new javax.swing.JLabel();
jTextField8 = new javax.swing.JTextField();
jLabel10 = new javax.swing.JLabel();
jTextField9 = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jLabel11 = new javax.swing.JLabel();
jTextField10 = new javax.swing.JTextField();
jButton3 = new javax.swing.JButton();
jLabel12 = new javax.swing.JLabel();
jButton4 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstan ts.EXIT_ON_CLOSE);
setName("Form"); // NOI18N
org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(m atthewproj.MatthewProjApp.class).getContext().getR esourceMap(JProgrammer.class);
jLabel1.setText(resourceMap.getString("jLabel1.tex t")); // NOI18N
jLabel1.setName("jLabel1"); // NOI18N
jSeparator1.setOrientation(javax.swing.SwingConsta nts.VERTICAL);
jSeparator1.setName("jSeparator1"); // NOI18N
jLabel2.setText(resourceMap.getString("jLabel2.tex t")); // NOI18N
jLabel2.setName("jLabel2"); // NOI18N
jTextField1.setText(resourceMap.getString("name.te xt")); // NOI18N
jTextField1.setName("name"); // NOI18N
jLabel3.setText(resourceMap.getString("jLabel3.tex t")); // NOI18N
jLabel3.setName("jLabel3"); // NOI18N
jTextField2.setText(resourceMap.getString("surname .text")); // NOI18N
jTextField2.setName("surname"); // NOI18N
jLabel4.setText(resourceMap.getString("jLabel4.tex t")); // NOI18N
jLabel4.setName("jLabel4"); // NOI18N
jTextField3.setText(resourceMap.getString("id.text ")); // NOI18N
jTextField3.setName("id"); // NOI18N
jLabel5.setText(resourceMap.getString("jLabel5.tex t")); // NOI18N
jLabel5.setName("jLabel5"); // NOI18N
jTextField4.setText(resourceMap.getString("address .text")); // NOI18N
jTextField4.setName("address"); // NOI18N
jLabel6.setText(resourceMap.getString("jLabel6.tex t")); // NOI18N
jLabel6.setName("jLabel6"); // NOI18N
jTextField5.setText(resourceMap.getString("city.te xt")); // NOI18N
jTextField5.setName("city"); // NOI18N
jLabel7.setText(resourceMap.getString("jLabel7.tex t")); // NOI18N
jLabel7.setName("jLabel7"); // NOI18N
jTextField6.setText(resourceMap.getString("telepho ne.text")); // NOI18N
jTextField6.setName("telephone"); // NOI18N
jLabel8.setText(resourceMap.getString("jLabel8.tex t")); // NOI18N
jLabel8.setName("jLabel8"); // NOI18N
jTextField7.setText(resourceMap.getString("ssid.te xt")); // NOI18N
jTextField7.setName("ssid"); // NOI18N
jLabel9.setText(resourceMap.getString("jLabel9.tex t")); // NOI18N
jLabel9.setName("jLabel9"); // NOI18N
jTextField8.setText(resourceMap.getString("pid.tex t")); // NOI18N
jTextField8.setName("pid"); // NOI18N
jLabel10.setText(resourceMap.getString("jLabel10.t ext")); // NOI18N
jLabel10.setName("jLabel10"); // NOI18N
jTextField9.setText(resourceMap.getString("hours.t ext")); // NOI18N
jTextField9.setName("hours"); // NOI18N
jButton1.setText(resourceMap.getString("jButton1.t ext")); // NOI18N
jButton1.setName("jButton1"); // NOI18N
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jButton2.setText(resourceMap.getString("jButton2.t ext")); // NOI18N
jButton2.setName("jButton2"); // NOI18N
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
jLabel11.setText(resourceMap.getString("jLabel11.t ext")); // NOI18N
jLabel11.setName("jLabel11"); // NOI18N
jTextField10.setText(resourceMap.getString("jTextF ield10.text")); // NOI18N
jTextField10.setName("jTextField10"); // NOI18N
jButton3.setText(resourceMap.getString("jButton3.t ext")); // NOI18N
jButton3.setName("jButton3"); // NOI18N
jLabel12.setText(resourceMap.getString("jLabel12.t ext")); // NOI18N
jLabel12.setName("jLabel12"); // NOI18N
jButton4.setText(resourceMap.getString("jButton4.t ext")); // NOI18N
jButton4.setName("jButton4"); // NOI18N
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout .Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.TRAILING)
.addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.LEADIN G, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.LEADING)
.addComponent(jLabel2)
.addComponent(jLabel3)
.addComponent(jLabel5)
.addComponent(jLabel6)
.addComponent(jLabel7)
.addComponent(jLabel8)
.addComponent(jLabel9)
.addComponent(jLabel10)
.addComponent(jLabel4))
.addGap(30, 30, 30)
.addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.LEADING)
.addComponent(jTextField9, javax.swing.GroupLayout.DEFAULT_SIZE, 113, Short.MAX_VALUE)
.addComponent(jTextField8, javax.swing.GroupLayout.DEFAULT_SIZE, 113, Short.MAX_VALUE)
.addComponent(jTextField7, javax.swing.GroupLayout.DEFAULT_SIZE, 113, Short.MAX_VALUE)
.addComponent(jTextField6, javax.swing.GroupLayout.DEFAULT_SIZE, 113, Short.MAX_VALUE)
.addComponent(jTextField5, javax.swing.GroupLayout.DEFAULT_SIZE, 113, Short.MAX_VALUE)
.addComponent(jTextField4, javax.swing.GroupLayout.DEFAULT_SIZE, 113, Short.MAX_VALUE)
.addComponent(jTextField3, javax.swing.GroupLayout.DEFAULT_SIZE, 113, Short.MAX_VALUE)
.addComponent(jTextField2, javax.swing.GroupLayout.DEFAULT_SIZE, 113, Short.MAX_VALUE)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addGap(67, 67, 67))
.addGroup(layout.createSequentialGroup()
.addGap(63, 63, 63)
.addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.TRAILING, false)
.addComponent(jButton2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 135, Short.MAX_VALUE))
.addGap(90, 90, 90)))
.addGap(4, 4, 4)
.addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel11)
.addGap(19, 19, 19)
.addComponent(jTextField10, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(36, 36, 36))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel12)
.addGap(68, 68, 68)
.addComponent(jButton4, javax.swing.GroupLayout.DEFAULT_SIZE, 160, Short.MAX_VALUE)
.addContainerGap())))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout .Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1)
.addGap(41, 41, 41)
.addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.Component Placement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.Component Placement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.BASELINE)
.addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel4))
.addPreferredGap(javax.swing.LayoutStyle.Component Placement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.BASELINE)
.addComponent(jLabel5)
.addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.Component Placement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.BASELINE)
.addComponent(jLabel6)
.addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.Component Placement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.BASELINE)
.addComponent(jLabel7)
.addComponent(jTextField6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.Component Placement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.BASELINE)
.addComponent(jLabel8)
.addComponent(jTextField7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.Component Placement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.BASELINE)
.addComponent(jLabel9)
.addComponent(jTextField8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.Component Placement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.BASELINE)
.addComponent(jLabel10)
.addComponent(jTextField9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(38, 38, 38)
.addComponent(jButton2)
.addGap(27, 27, 27)
.addComponent(jButton1))
.addGroup(layout.createSequentialGroup()
.addGap(59, 59, 59)
.addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.BASELINE)
.addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton3)
.addComponent(jTextField10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(30, 30, 30)
.addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.BASELINE)
.addComponent(jLabel12)
.addComponent(jButton4)))
.addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 497, javax.swing.GroupLayout.PREFERRED_SIZE)
);
pack();
}// </editor-fold>
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
jTextField1.setText("");
jTextField2.setText("");
jTextField3.setText("");
jTextField4.setText("");
jTextField5.setText("");
jTextField6.setText("");
jTextField7.setText("");
jTextField8.setText("");
jTextField9.setText("");
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
Connection connection = null;
try {
Class.forName(DRIVER);
connection = DriverManager.getConnection(URL);
String insertSQL = "Insert into ProgTable(jTextField3,,jTextField1,jTextField2,jTe xtField3,jTextField4,jTextField5,jTextField6,jText Field7,jTextField8,jTextField9) " +
"values(?,?,?,?,?,?,?);";
// int rows = statement.executeUpdate(sql);
// System.out.printf(jTextField1.getText());
} catch (ClassNotFoundException ex) {
} catch (SQLException e) {
e.printStackTrace();
} finally {
try {
connection.close();
} catch (SQLException ex) {
Logger.getLogger(DeleteProg.class.getName()).log(L evel.SEVERE, null, ex);
}
}
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new JProgrammer().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JButton jButton4;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JSeparator jSeparator1;
private javax.swing.JTextField jTextField1;
private javax.swing.JTextField jTextField10;
private javax.swing.JTextField jTextField2;
private javax.swing.JTextField jTextField3;
private javax.swing.JTextField jTextField4;
private javax.swing.JTextField jTextField5;
private javax.swing.JTextField jTextField6;
private javax.swing.JTextField jTextField7;
private javax.swing.JTextField jTextField8;
private javax.swing.JTextField jTextField9;
// End of variables declaration
}
- 02-07-2009, 06:16 PM #2
First of all don't use thread topics like "urgent, help", try describing in a few words what you're doing instead. Secondly post code in code tags: [c] write code here [/c] except replace "c" with "CODE". Thirdly, Describe the error. It's a nullpointer, but it probably told you where in your code the exception is. Most importantly, Do not put so much code. Isolate the code that has the problem and just show that. Only the most patient people here will take the time to read your code with no CODE tags, and extremely long with no indication of what could have caused the error. Don't just say hi nicely, say here's a sample and post pages of code and expect people to go through all of it.
And, you should have searched the internet to find out what a null pointer is. It means that something in your code uses of has a reference to a variable who's value is null. So find it and give it a value. We can't find it because you gave no indication whatsoever where the exception occured.Last edited by MK12; 02-07-2009 at 06:19 PM.
Tell me if you want a cool Java logo avatar like mine and I'll make you one.
Similar Threads
-
Urgent help needed here pls!!
By Manfizy in forum NetBeansReplies: 5Last Post: 01-28-2009, 07:38 AM -
SJF Dynamic DataTable **Urgent Help Needed**
By pathan.umapathi@gmail.com in forum JavaServer Faces (JSF)Replies: 1Last Post: 09-26-2008, 06:50 AM -
Urgent Java programmer needed.
By KevinG in forum Jobs OfferedReplies: 5Last Post: 04-23-2008, 04:02 AM -
urgent help needed - paper submission.
By dirtycash in forum New To JavaReplies: 2Last Post: 11-23-2007, 11:24 AM -
urgent help needed for [application-${environment}.properties]
By deepman in forum Advanced JavaReplies: 0Last Post: 08-14-2007, 09:31 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks