• 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

JDBC-View

 
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
When we use jdbc to retrieve data from database, we usually select the column from tables. Can we retrieve data from a view. If yes, how?
 
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why not? Once a view is created you can (for the most part) treat it just as it would be a table.
 
Mike Yu
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Leslie,
Thank you for your reply. I know a view is like a table. But could you please show an example using JDBC?
 
Ranch Hand
Posts: 1143
1
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mike,
So you know what a database view is -- good!
So do you know how to retrieve data from a database table using JDBC? If you do, then (as Leslie has implied), just replace the table with the view -- it's that simple.
On the other hand, if you are really asking for someone to show you how to perform a database query using JDBC, there are (in my opinion) more suitable resources than a forum. Have you seen these tutorials:
http://java.sun.com/docs/books/tutorial/jdbc/index.html
http://developer.java.sun.com/developer/onlineTraining/Database/JDBC20Intro/
If you are using Oracle as your DBMS, they have sample code that comes as part of the database installation, and they have many samples here:
http://technet.oracle.com/sample_code/tech/java/sqlj_jdbc/content.html
If you also know how to query a database table using JDBC (as well as knowing what a view is :-), then are you familiar with the phrase "suck it and see", or "there's only one way to find out"?
In other words, have you tried querying your view using JDBC? Are you not succeeding? Perhaps you would care to show us the code you are trying and the error message you get when it fails?
Hope this has helped you.
Good Luck,
Avi.
 
reply
    Bookmark Topic Watch Topic
  • New Topic