Welcome to Dream.In.Code
Getting Help is Easy!

Join 98,765 Programmers for FREE!. Ask your question and get quick answers from Dream.In.Code experts. There are 1,055 online right now! We're the #1 programming help community on the internet! Registration is fast and FREE... Join Now!

Chat LIVE With a Expert

Register to Make This Box Go Away!


SEVERE: null

 
Reply to this topicStart new topic

SEVERE: null, Displaying information from a database

theplaymaker
post 22 Apr, 2008 - 11:29 AM
Post #1


New D.I.C Head

*
Joined: 9 Sep, 2007
Posts: 9


My Contributions


Hi

I have created a database from reading a text file, but I'm having problems displaying data in a text area. I am using Netbeans IDE 6.0.

This is the error:
SEVERE: null
java.sql.SQLException: Column Index out of range, 2 > 1.
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:910)
at com.mysql.jdbc.ResultSet.checkColumnBounds(ResultSet.java:690)
at com.mysql.jdbc.ResultSet.getStringInternal(ResultSet.java:5625)
at com.mysql.jdbc.ResultSet.getString(ResultSet.java:5544)

The following code works:
CODE

  try {
                rs = db.query("SELECT * FROM tblCommunity");
                txaDisplay.setText(processTblChest(rs));
            } catch (SQLException ex) {
                Logger.getLogger(mainGUI.class.getName()).log(Level.SEVERE, null, ex);
            }  


The following code does not work:
CODE

  try {
                rs = db.query("SELECT selection FROM tblCommunity WHERE chestID = 3");
                txaDisplay.setText(processTblChest(rs));
            } catch (SQLException ex) {
                Logger.getLogger(mainGUI.class.getName()).log(Level.SEVERE, null, ex);
            }  


Sample of text file:
1#Move forward by 2 spaces#2#3#
2#Move forward by 5 spaces#5#3#
3#Move back 3 spaces#-3#3#
4#Move back 5 spaces#-5#3#

The following code is a sample of the variable type:
CODE

db.update("CREATE TABLE namesdata.tblCommunity(chestID INTEGER, Descrip CHAR(100), Amount INTEGER, Selection INTEGER, PRIMARY KEY(chestID));");


Thanks
User is offlineProfile CardPM

Go to the top of the page


Trogdor
post 5 May, 2008 - 03:03 AM
Post #2


D.I.C Regular

Group Icon
Joined: 6 Oct, 2006
Posts: 398



Thanked 1 times

Dream Kudos: 125
My Contributions


aparently the function processTblChest(rs) can not handle a resultset with more then one column.
using SELECT * is always tricky, better specify columnnames.
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 7/20/08 02:47PM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month
-->