• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Retrieving data from database

 
Shahid Kahn
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


At Line 41, no data is retrieved. But there is no compile time error, no runtime error.
If I try to query data from other table it works fine. It does not work for ordr_product table.
I ran the query on sqlplus, it worked fine.
Can you tell me where I am going wrong.

my JSP is
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you confirm the data is committed? (Type commit; in SQL Plus) That would explain the query working in one and not the other.

Also, can you try changing your JDBC code to run the query SELECT * FROM ORDR_PRODUCT. This will tell if the problem is in the where clause. Maybe it is lowercase vs uppercase or there is trailing whitespace?
 
Shahid Kahn
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, the issue was with the WHERE clause.
The database field was ORDR_ID CHAR(12), but the value I was matching against was of 11 bytes.
I changed the database column and it is working now.
But why is it like this? My string to be match was of smaller length than that of database.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Shadi,
Yes, that's the difference between char and varchar. char stores exactly X characters. varchar stores a smaller amount if present. Varchar also has the advantage of using less disk space since it only stores what is needed.
 
Javier Arroyo-Figueroa
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For cases like this you may want to do an isolated test of your JSP using a tool like JspTester. This way you make sure that nothing is wrong with your JSP, so you can isolate the problem better.

Link: http://www.jsptester.com. Hope this helps.
 
Brian Tkatch
Bartender
Posts: 567
25
Linux Notepad Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On a side note, please do not use "SELECT *" outside of EXISTS() and ad hoc queries. Specifying the column name(s) is self documenting, and protects against new and removed columns, and possible reordering. It also makes sure you only get the data you need, adding a bit of network and processing efficiency.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic