code: public DatabaseInfo getDatabaseInfo(Connection connection) throws SQLException
      {
          PreparedStatement statement = connection.prepareStatement("select @@servername, db_name()");
          ResultSet results = null;
          DatabaseInfo info = null;
  
          try
          {
              results = statement.executeQuery();
  
              if (!results.next())
              {
                  throw new SQLException("Query for database name and server name returned zero rows!");
              }
  
              info = new DatabaseInfo(results.getString(1), results.getString(2));
          }
          finally
          {
              closeResultSet(results, "Ignoring error whilst closing ResultSet that was used to query the DatabaseInfo");
  
              closeStatement(statement, "Ignoring error whilst closing PreparedStatement that was used to query the DatabaseInfo");
          }
  
          return info;
      }
docs: Gets the <code>DatabaseInfo</code> for a particular connection.
  @param connection The connection to lookup the database information from.
  @return The database information.
  @throws SQLException if there was a problem looking up the database information.