Returns the {@link HsqlDatabaseDescriptor} with the given name.
518936
@Override
	public HsqlDatabaseDescriptor dbByName(final String dbName) {
		Collection<HsqlDatabaseDescriptor> select = CollectionUtils.select(dbs,
				new Predicate<HsqlDatabaseDescriptor>() {

					@Override
					public boolean evaluate(HsqlDatabaseDescriptor db) {
						return dbName.equals(db.getDbName());
					}

				});
		if (CollectionUtils.size(select) == 0) {
			throw new IllegalArgumentException(
					"There are no databases called '" + dbName + "'");
		}
		if (CollectionUtils.size(select) >= 2) {
			throw new IllegalArgumentException(
					"More than one database is called '" + dbName + "'");
		}
		return CollectionUtils.extractSingleton(select);
	}
1244105
String tableNameForIndexName(String indexName) {
        // the schema manager has a map of indexes by name
        // if this shows up on profiles, you can try to use that, but beware
        // the case insensitivity going on here
        HashMappedList hsqlTables = getHSQLTables();
        for (int i = 0; i < hsqlTables.size(); i++) {
            Table table = (Table) hsqlTables.get(i);
            for (Index index : table.getIndexList()) {
                if (index.getName().name.equalsIgnoreCase(indexName)) {
                    return table.getName().name.toLowerCase();
                }
            }
        }
        return null;
    }
953924
public static Optional<EmbeddedJdbcDatabase> get(ClassLoader classLoader) {
        return databases
            .stream()
            .filter(JdbcDatabase::isEmbedded)
            .map(EmbeddedJdbcDatabase.class::cast)
            .filter(embeddedDatabase -> ClassUtils.isPresent(embeddedDatabase.getDriverClassName(), classLoader))
            .findFirst();
    }
853781
public static DataSource getJndiDs(String jndiName) {
		try {
			return (DataSource) new InitialContext().lookup(jndiName);
		} catch (NamingException e) {
			throw new DbRuntimeException(e);
		}
	}
1214863
public FieldDescriptor getFieldDescriptorByName(String name)
    {
        if (name == null || m_FieldDescriptions == null)
        {
            return null;
        }

        if (m_fieldDescriptorNameMap == null)
        {
            HashMap nameMap = new HashMap();

            FieldDescriptor[] descriptors = getFieldDescriptions();
            for (int i = descriptors.length - 1; i >= 0; i--)
            {
                FieldDescriptor fld = descriptors[i];
                nameMap.put(fld.getPersistentField().getName(), fld);
            }

            m_fieldDescriptorNameMap = nameMap;
        }

        return (FieldDescriptor) m_fieldDescriptorNameMap.get(name);
    }
985264
private TenantDefinition getTenantDef(String tenantName) {
        DRow tenantDefRow = DBService.instance().getRow(TENANTS_STORE_NAME, tenantName);
        if (tenantDefRow == null) {
            return null;
        }
        return loadTenantDefinition(tenantDefRow);
    }
284784
public List<DatastoreDescriptor> getAvailableDatabaseBasedDatastoreDescriptors() {
        final List<DatastoreDescriptor> availableCloudBasedDatabaseDescriptors = new ArrayList<>();

        availableCloudBasedDatabaseDescriptors.add(POSTGRESQL_DATASTORE_DESCRIPTOR);
        availableCloudBasedDatabaseDescriptors.add(SQLSERVER_DATASTORE_DESCRIPTOR);
        availableCloudBasedDatabaseDescriptors.add(ELASTICSEARCH_DATASTORE_DESCRIPTOR);
        availableCloudBasedDatabaseDescriptors.add(HBASE_DATASTORE_DESCRIPTOR);
        availableCloudBasedDatabaseDescriptors.add(HIVE_DATASTORE_DESCRIPTOR);
        availableCloudBasedDatabaseDescriptors.add(CASSANDRA_DATASTORE_DESCRIPTOR);
        availableCloudBasedDatabaseDescriptors.add(MONGODB_DATASTORE_DESCRIPTOR);
        availableCloudBasedDatabaseDescriptors.add(COUCHDB_DATASTORE_DESCRIPTOR);
        availableCloudBasedDatabaseDescriptors.add(DYNAMODB_DATASTORE_DESCRIPTOR);
        availableCloudBasedDatabaseDescriptors.add(KAFKA_DATASTORE_DESCRIPTOR);
        availableCloudBasedDatabaseDescriptors.add(NEO4J_DATASTORE_DESCRIPTOR);

        return availableCloudBasedDatabaseDescriptors;
    }
436333
public DbDatum getDatum(String name) {
        for (DbDatum datum : this) {
            if (name.equalsIgnoreCase(datum.name))
                return datum;
        }
        return null;
    }
1160630
public static HSQLDDLInfo preprocessHSQLDDL(String ddl) {
        ddl = SQLLexer.stripComments(ddl);

        Matcher matcher = HSQL_DDL_PREPROCESSOR.matcher(ddl);
        if (matcher.find()) {
            String verbString = matcher.group("verb");
            HSQLDDLInfo.Verb verb = HSQLDDLInfo.Verb.get(verbString);
            if (verb == null) {
                return null;
            }

            String nounString = matcher.group("object");
            HSQLDDLInfo.Noun noun = HSQLDDLInfo.Noun.get(nounString);
            if (noun == null) {
                return null;
            }
            boolean createStream = verb.equals(HSQLDDLInfo.Verb.CREATE) &&
                                   noun.equals(HSQLDDLInfo.Noun.STREAM);

            String name = matcher.group("name");
            if (name == null) {
                return null;
            }

            String secondName = matcher.group("subject");
            if (secondName != null) {
                secondName = secondName.toLowerCase();
            }

            // cascade/if exists are interesting on alters and drops
            boolean cascade = false;
            boolean ifexists = false;
            if (verb != HSQLDDLInfo.Verb.CREATE) {
                matcher = DDL_IFEXISTS_OR_CASCADE_CHECK.matcher(ddl);
                if (matcher.matches()) {
                    // Don't be too sensitive to regex specifics by assuming null always
                    // indicates a missing clause. Look for empty too.
                    String existsClause = matcher.group("exists");
                    String cascadeClause = matcher.group("cascade");
                    ifexists = existsClause != null && !existsClause.isEmpty();
                    cascade = cascadeClause != null && !cascadeClause.isEmpty();
                }
            }

            return new HSQLDDLInfo(verb, noun, name.toLowerCase(), secondName, cascade, ifexists, createStream);
        }
        return null;
    }
992737
@Deprecated 
	private String convertDatabaseName(String name) {
		if (propBase.getBooleanProperty("db.useUnderscoreNaming")) {
			name = CamelCaseConverter.camelCaseToUnderscore(name);
		}
		name = truncateLongDatabaseName(name);
		name = name.toUpperCase();
		return name;
	}
165908
@Override
	@Deprecated
	public DataSource dataSourceByName(String dbName) {
		return new com.danidemi.jlubricant.embeddable.BasicDataSource(
				dbByName(dbName));
	}
207089
public IndexDef getIndex(String name)
    {
        String   realName = (name == null ? "" : name);
        IndexDef def      = null;

        for (Iterator it = getIndices(); it.hasNext();)
        {
            def = (IndexDef)it.next();
            if (def.getName().equals(realName))
            {
                return def;
            }
        }
        return null;
    }
314652
private String toSQLClause(SelectionCriteria c, ClassDescriptor cld)
    {
        String colName = toSqlClause(c.getAttribute(), cld);
        return colName + c.getClause() + " ? ";
    }
1240458
protected String getDBCreationUrl()
    {
        JdbcConnectionDescriptor jcd = getConnection();

        // currently I only know about specifics for mysql
        if (TORQUE_PLATFORM_MYSQL.equals(getTargetTorquePlatform()))
        {
            // we have to remove the db name as the jdbc driver would try to connect to
            // a non-existing db
            // the db-alias has this form: [host&port]/[dbname]?[options]
            String dbAliasPrefix = jcd.getDbAlias();
            String dbAliasSuffix = "";
            int    questionPos   = dbAliasPrefix.indexOf('?');

            if (questionPos > 0)
            {
                dbAliasSuffix = dbAliasPrefix.substring(questionPos);
                dbAliasPrefix = dbAliasPrefix.substring(0, questionPos);
            }

            int slashPos = dbAliasPrefix.lastIndexOf('/');

            if (slashPos > 0)
            {
                // it is important that the slash at the end is present
                dbAliasPrefix = dbAliasPrefix.substring(0, slashPos + 1);
            }
            return jcd.getProtocol()+":"+jcd.getSubProtocol()+":"+dbAliasPrefix+dbAliasSuffix;
        }
        else if (TORQUE_PLATFORM_POSTGRESQL.equals(getTargetTorquePlatform()))
        {
            // we have to replace the db name with 'template1'
            // the db-alias has this form: [host&port]/[dbname]?[options]
            String dbAliasPrefix = jcd.getDbAlias();
            String dbAliasSuffix = "";
            int    questionPos   = dbAliasPrefix.indexOf('?');

            if (questionPos > 0)
            {
                dbAliasSuffix = dbAliasPrefix.substring(questionPos);
                dbAliasPrefix = dbAliasPrefix.substring(0, questionPos);
            }

            int slashPos = dbAliasPrefix.lastIndexOf('/');

            if (slashPos > 0)
            {
                // it is important that the slash at the end is present
                dbAliasPrefix = dbAliasPrefix.substring(0, slashPos + 1);
            }
            else
            {
                dbAliasPrefix += "/";
            }
            dbAliasPrefix += "template1";
            if (dbAliasSuffix.length() > 0)
            {
                dbAliasPrefix += "/";
            }
            return jcd.getProtocol()+":"+jcd.getSubProtocol()+":"+dbAliasPrefix+dbAliasSuffix;
            
        }
        else
        {
            return jcd.getProtocol()+":"+jcd.getSubProtocol()+":"+jcd.getDbAlias();
        }
    }
807793
static public HsqlName getAutoColumnName(int i) {

        if (i < autoColumnNames.length) {
            return autoColumnNames[i];
        }

        return new HsqlName(staticManager, makeAutoColumnName("C_", i), 0, false);
    }
941996
public String determineDatabaseName() {
		if (this.generateUniqueName) {
			if (this.uniqueName == null) {
				this.uniqueName = UUID.randomUUID().toString();
			}
			return this.uniqueName;
		}
		if (StringUtils.hasLength(this.name)) {
			return this.name;
		}
		if (this.embeddedDatabaseConnection != EmbeddedDatabaseConnection.NONE) {
			return "testdb";
		}
		return null;
	}
928847
public Reference getReference() throws NamingException {

        String    cname = "org.hsqldb_voltpatches.jdbc.JDBCDataSourceFactory";
        Reference ref   = new Reference(getClass().getName(), cname, null);

        ref.add(new StringRefAddr("database", getDatabase()));
        ref.add(new StringRefAddr("user", getUser()));
        ref.add(new StringRefAddr("password", password));

        return ref;
    }