• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

problem in Access database.

 
Ranch Hand
Posts: 1143
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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..
 
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 1143
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)));
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:


 
Ranch Hand
Posts: 859
IBM DB2 Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Saloon Keeper
Posts: 7585
176
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

java.sql.SQLException: No data found


That is an awesome error message.
 
Punit Jain
Ranch Hand
Posts: 1143
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 1143
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 1143
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 1143
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 1143
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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....
reply
    Bookmark Topic Watch Topic
  • New Topic