Win a copy of Terraform in Action this week in the Cloud forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Retrieving data from database

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author & internet detective
Posts: 40801
829
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 40801
829
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 598
26
Oracle Notepad Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic