Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-10-2008, 09:57 PM
Member
 
Join Date: May 2008
Posts: 29
adeeb is on a distinguished road
NullPointerException
Hi,
In my program i don't have any errors while compiling but i am getting this error while compiling:
Here is the Error code:
"Exception in thread "main" java.lang.NullPointerException
at library.<init>(library.java:205)
at library.main(library.java:515)
Press any key to continue..."

The program code is below starting from the line number 205 as indicated in error. The below code is written under ActionListener:

find.addActionListener(new ActionListener()
{

public void actionPerformed(ActionEvent e)
{
Vector columnNames = new Vector();
Vector data = new Vector();
try
{
String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
Class.forName( driver );
Connection connection = DriverManager.getConnection( "jdbc dbc:addissue","library", "bismillah" );

String sql = "Select * from addissue ORDER BY rollno ASC";
Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery( sql );
ResultSetMetaData md = rs.getMetaData();
int columns = md.getColumnCount();

// Get column names

for (int i = 1; i <= columns; i++)
{
columnNames.addElement( md.getColumnName(i) );
}

// Get row data

while (rs.next())
{
Vector row = new Vector(columns);

for (int i = 1; i <= columns; i++)
{
row.addElement( rs.getObject(i) );
}

data.addElement( row );
}

rs.close();
stmt.close();
}
catch(Exception ce)
{
System.out.println( ce );
}

JTable tab = new JTable(data, columnNames);
JScrollPane jsp = new JScrollPane(tab);

}
});

ftf = new JTextField(20);
ftf1 = new JTextField(20);
froll = new JLabel("Roll No");
fname = new JLabel("Name");
find = new JButton("Find");

GroupLayout gl5 = new GroupLayout(jp5);
jp5.setLayout(gl5);
gl5.setAutoCreateGaps(true);
gl5.setAutoCreateContainerGaps(true);
gl5.setHorizontalGroup(gl5.createSequentialGroup()
.addGroup(gl5.createParallelGroup(LEADING)
.addComponent(froll)
.addComponent(fname))
.addGroup(gl5.createParallelGroup(LEADING)
.addComponent(ftf)
.addComponent(ftf1)
.addComponent(find, (CENTER))
.addComponent(jsp))
);

gl5.setVerticalGroup(gl5.createSequentialGroup()
.addGroup(gl5.createParallelGroup(BASELINE)
.addComponent(froll)
.addComponent(ftf))
.addGroup(gl5.createParallelGroup(BASELINE)
.addComponent(fname)
.addComponent(ftf1))
.addGroup(gl5.createParallelGroup(BASELINE)
.addComponent(find))
.addGroup(gl5.createParallelGroup(BASELINE)
.addComponent(jsp))
);
this was the code for adding a table with few other components to a panel.
Thanks and Regard.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 06-11-2008, 04:56 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,959
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
One of your member not get the correct value, and set null at run time. Do you have debug and see where it happened?
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
(Close on September 4, 2008)

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 06-11-2008, 08:41 AM
Member
 
Join Date: May 2008
Posts: 29
adeeb is on a distinguished road
Hey,
Eranga
Now i am getting the following error

Exception in thread "main" java.lang.IllegalArgumentException: Component must be
non-null
at javax.swing.GroupLayout$ComponentSpring.<init>(Gro upLayout.java:2878)

at javax.swing.GroupLayout$ComponentSpring.<init>(Gro upLayout.java:2858)

at javax.swing.GroupLayout$Group.addComponent(GroupLa yout.java:1490)
at javax.swing.GroupLayout$SequentialGroup.addCompone nt(GroupLayout.java
:1771)
at javax.swing.GroupLayout$SequentialGroup.addCompone nt(GroupLayout.java
:1713)
at javax.swing.GroupLayout$Group.addComponent(GroupLa yout.java:1471)
at javax.swing.GroupLayout$SequentialGroup.addCompone nt(GroupLayout.java
:1746)
at library.<init>(library.java:212)
at library.main(library.java:518)
Press any key to continue...
Now what to do
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 06-11-2008, 09:42 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,959
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
I hope something wrong with GroupLayout.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
(Close on September 4, 2008)

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
NullPointerException mensa Java 2D 5 05-04-2008 12:19 AM
NullPointerException ravian New To Java 2 12-07-2007 05:20 PM
NullPointerException Feng New To Java 5 11-24-2007 08:51 PM
nullPointerException problem conandor Networking 1 08-14-2007 02:22 PM
ERROR: nullPointerException mathias New To Java 1 08-05-2007 07:54 AM


All times are GMT +3. The time now is 10:12 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org