Import java. SQL .*;
Public class GetDBInfo
{
Public GetDBInfo ()
{
}
Public static void main (String [] args)
{
Try {
Class. forName ("com. microsoft. jdbc. sqlserver. SQLServerDriver"). newInstance ();
String url = "jdbc: microsoft: sqlserver: // GAOXIANG: 1433; DataBaseName = master ";
String user = "daryl715 ";
String pass = "1234 ";
String s;
Connection con = DriverManager. getConnection (url, user, pass );
DatabaseMetaData dbmd = con. getMetaData ();
S = dbmd. getDriverName ();
System. out. println ("The driver name is:" + s );
System. out. println ("");
S = dbmd. getDatabaseProductName ();
System. out. println ("Database Name:" + s );
System. out. println ("");
ResultSet rs = dbmd. getSchemas ();
System. out. println ("mode names :");
While (rs. next ())
System. out. print ("" + rs. getString (1 ));
System. out. println ();
S = dbmd. getSQLKeywords ();
System. out. println ("keyword in SQL:" + s );
System. out. println ("");
Int max = dbmd. getMaxColumnNameLength ();
System. out. println ("the maximum length of the column name can be:" + max );
System. out. println ("");
Max = dbmd. getMaxTableNameLength ();
System. out. println ("the maximum table name length can be:" + max );
System. out. println ("");
Max = dbmd. getMaxColumnsInSelect ();
System. out. println ("the maximum length of the column name that can be returned by a select clause is:" + max );