This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem in Access database.

 
Punit Jain
Ranch Hand
Posts: 1015
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have a table in msAccess one column in that table has a datatype number.
but when i m fetching the value from database, this field value is not coming from my db, it showing me exception:


but my data is exist in that column in table..

also i want to know, if my table is table(access) is opened it will not run my project.
what i need to do if i want to run my project, even if my table is opened??

Thank you..
 
Wendy Gibbons
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Punit, we are going to need to see the select statement, and you will need to run it against the database using a viewer as well
 
Punit Jain
Ranch Hand
Posts: 1015
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here is my function to fetch records:


and here i am displaying all the records:


it displaying all the records except the int values, this one: txtFeeDue.setText(String.valueOf(res.getInt(14)));
 
Rob Spoor
Sheriff
Pie
Posts: 20667
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you sure your table has at least 18 columns?
You should never use SELECT *. It doesn't tell you which columns are returned, but more importantly, it also guarantees no order. If you add another column between two existing columns, all your logic will break. So just mention all the columns you want in the SELECT statement.
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Punit Jain wrote:it displaying all the records except the int values, this one: txtFeeDue.setText(String.valueOf(res.getInt(14)));


And is that because the exception you originally mentioned is still being thrown? Or is that field just not appearing?

In the latter case it's probably because you're writing the data to a component which isn't in the GUI:


 
William P O'Sullivan
Ranch Hand
Posts: 859
Chrome IBM DB2 Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul has it I think..

You need to add that txtField to the panel or container or whatever.

Also you should change your select to something like "select col1,col2,col3 from ..."
then in the Java code access the rs using:


This gives you much greater control over future DB changes and unforeseen ordering changes,
such as alter table add colx after col2 etc..

WP
 
Tim Moores
Bartender
Posts: 2954
46
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java.sql.SQLException: No data found

That is an awesome error message.
 
Punit Jain
Ranch Hand
Posts: 1015
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Are you sure your table has at least 18 columns?

yes

You should never use SELECT *. It doesn't tell you which columns are returned, but more importantly, it also guarantees no order. If you add another column between two existing columns, all your logic will break. So just mention all the columns you want in the SELECT statement.

i have changed * to all my column names.
 
Punit Jain
Ranch Hand
Posts: 1015
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

And is that because the exception you originally mentioned is still being thrown? Or is that field just not appearing?

if i m trying to print that value, it showing me exception.
but i m just adding that value to textBox, it not showing me exception, but also no data appear in that field.


In the latter case it's probably because you're writing the data to a component which isn't in the GUI:


what do you mean by this?
you mean that i have not declared txtFeeDue, but i have declared it in my code, i have not posted my whole code..
 
Punit Jain
Ranch Hand
Posts: 1015
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

You need to add that txtField to the panel or container or whatever.

but i m doing this:



Also you should change your select to something like "select col1,col2,col3 from ..."
then in the Java code access the rs using:


done, still the problem is same.
 
Punit Jain
Ranch Hand
Posts: 1015
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have also changed the type to string, but still it showing me the same exception, might be the problem is somewhere in my code..
my search class has arround 430 lines of code, should i post that here??
 
Punit Jain
Ranch Hand
Posts: 1015
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
okay...
it's working..
i have changed my datatype to string..
also i was initializing my jtextfield twice..

Thank you all....
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic