Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JDBC-View

 
Mike Yu
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
  • 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?
 
Leslie Chaim
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
  • 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
  • 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?
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic