File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes DatabaseMetaData Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "DatabaseMetaData" Watch "DatabaseMetaData" New topic
Author

DatabaseMetaData

Fisher Daniel
Ranch Hand

Joined: Sep 14, 2001
Posts: 582
Hi all,
I want to develop an application to retrieve all information about Database Management System.
I use DatabaseMetaData to get those information.
I see all the method on that interface always throw SQLException.
How can I distinguish about SQLException whether it is connection error or that database management system is not supported a feature?

thanks
daniel
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 26184
    
  66

Daniel,
The exception getMessage() will provide more information. The actual message is database dependent. But you can try it once by hand and see what message your database gives for connection errors. (try turning off the database or pointing at a non-existant database to do this)


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Fisher Daniel
Ranch Hand

Joined: Sep 14, 2001
Posts: 582
Hi Jeanne,
I tried my application with Oracle Database.
And some feature is not supported by Oracle, the JDBC driver will throw SQLException with message "Unsupported feature".

Oh.. I am sorry to not describe my application clearly.
My application will display all database's features.
If there is a feature that a database doesn't support so I want my application will display "Not Available".
Because of that I want to know how I can distinguish the error message within SQLException.

Hope this help you to understand my case..
Thank you very much for your attention

daniel
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 26184
    
  66

Daniel,
Try something like this:

Then you can have CustomerUnsupportedException redirect to an error page or otherwise display a clear message.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: DatabaseMetaData
 
Similar Threads
MySQL table last update
How to determine 1:1, 1:M etc. relationships using DatabaseMetaData
Hibernate: How to tell the DB who is updating data
how to get the table constraints?
Help