A
Andy
Is there anyway to check to see if a database exists before I try and
establish a connection to it using JDBC? (I'm trying this out in MySQL
but I would like to understand it for any database system so I want to
avoid vendor specific info).
It seems like the only two options are to either make a call to the
system database and see if the requested database is in its list, which
seems a little ugly, or to make the call to getconnection and then
respond to the different SQLStates within the exception generated. My
concern/question about this latter option (which seems to be more
appropriate) is what are the various SQLState values? I have tried
searching the net for a list of the state values for XOPEN and SQL99
but it seems every web reference consists of the description about
SQLState and how it uses the standard XOPEN or SQL99 specs. I am unable
to find any reference that actually gives me those specs :-(
While I can run the program and build a list of State values for
various conditions, I am loathe to doing it this way as I have no way
of knowing whether I am missing certain key conditions and whether the
responses are universal to different DBMS.
Surely this is such a basic common process that thousands of people
must have addressed this problem already. Most source code examples I
have come across seem to just assume that the database exists and that
the username and password are correct.
regards
Andy
establish a connection to it using JDBC? (I'm trying this out in MySQL
but I would like to understand it for any database system so I want to
avoid vendor specific info).
It seems like the only two options are to either make a call to the
system database and see if the requested database is in its list, which
seems a little ugly, or to make the call to getconnection and then
respond to the different SQLStates within the exception generated. My
concern/question about this latter option (which seems to be more
appropriate) is what are the various SQLState values? I have tried
searching the net for a list of the state values for XOPEN and SQL99
but it seems every web reference consists of the description about
SQLState and how it uses the standard XOPEN or SQL99 specs. I am unable
to find any reference that actually gives me those specs :-(
While I can run the program and build a list of State values for
various conditions, I am loathe to doing it this way as I have no way
of knowing whether I am missing certain key conditions and whether the
responses are universal to different DBMS.
Surely this is such a basic common process that thousands of people
must have addressed this problem already. Most source code examples I
have come across seem to just assume that the database exists and that
the username and password are correct.
regards
Andy