This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes Searching Database Tables Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Searching Database Tables" Watch "Searching Database Tables" New topic

Searching Database Tables

Faisal Fuad
Ranch Hand

Joined: Jul 05, 2011
Posts: 83

Need some Hints. I would like to create a search engine type stuff where user will enter ID and press enter which then will go all the available tables into the database one by one, search of that ID and if found then present all the related information of that ID along with the Table name.

Now important point to note is that, in database each table colum formats are different and there i am facing the problem.

I have done this stuff in VB.NET and thats very simple by using GridView. But how can i do that with JSP-Servlet? I have to show each table name, there column title names as well as related info about the selected ID below the column title row.

I read some articles where many of them are doing this:

But that is sort of hard coded right? In this case You know the column title and so you can do the above thing. What if you only know the table name but don't know the column structure for each table. Then?

Hope i explain the problem clearly. Please give me some nice hints. Thanks
Madhan Sundararajan Devaki
Ranch Hand

Joined: Mar 18, 2011
Posts: 312

In JDBC, you have *MetaData interfaces that will give you the information you need.

Not many get the right opportunity !
Santhosh ayiappan
Ranch Hand

Joined: Jan 30, 2007
Posts: 80

below code would give you the column names of a particular table.

Faisal Fuad
Ranch Hand

Joined: Jul 05, 2011
Posts: 83

Thank you both. Specially Santhosh...your given sample code did save a lot of my time.
God bless
I agree. Here's the link:
subject: Searching Database Tables
It's not a secret anymore!