<";
+
+ /**
+ * Construct a new database connections. Note that not all these parameters are not always mandatory.
+ *
+ * @param name The database name
+ * @param type The type of database
+ * @param access The type of database access
+ * @param host The hostname or IP address
+ * @param db The database name
+ * @param port The port on which the database listens.
+ * @param user The username
+ * @param pass The password
+ */
+ public DatabaseMeta(String name, String type, String access, String host, String db, String port, String user,
+ String pass) {
+ setValues(name, type, access, host, db, port, user, pass);
+ addOptions();
+ }
+
+ /**
+ * Create an empty database connection
+ */
+ public DatabaseMeta() {
+ setDefault();
+ addOptions();
+ }
+
+ /**
+ * Set default values for an Oracle database.
+ */
+ public void setDefault() {
+ setValues("", "Oracle", "Native", "", "", "1521", "", "");
+ }
+
+ /**
+ * Add a list of common options for some databases.
+ */
+ public void addOptions() {
+ PluginInterface mySqlPlugin = PluginRegistry.getInstance().getPlugin(DatabasePluginType.class, "MYSQL");
+ PluginInterface infoBrightPlugin =
+ PluginRegistry.getInstance().getPlugin(DatabasePluginType.class, new InfobrightDatabaseMeta());
+
+ String mySQL = mySqlPlugin.getIds()[0];
+
+ addExtraOption(mySQL, "defaultFetchSize", "500");
+ addExtraOption(mySQL, "useCursorFetch", "true");
+
+ String infoBright = infoBrightPlugin.getIds()[0];
+
+ addExtraOption(infoBright, "characterEncoding", "UTF-8");
+
+ // Modern databases support this, try it by default...
+ //
+ setSupportsBooleanDataType(true);
+ setSupportsTimestampDataType(true);
+ }
+
+ /**
+ * @return the system dependend database interface for this database metadata definition
+ */
+ public DatabaseInterface getDatabaseInterface() {
+ return databaseInterface;
+ }
+
+ /**
+ * Set the system dependend database interface for this database metadata definition
+ *
+ * @param databaseInterface the system dependend database interface
+ */
+ public void setDatabaseInterface(DatabaseInterface databaseInterface) {
+ this.databaseInterface = databaseInterface;
+ }
+
+ /**
+ * Search for the right type of DatabaseInterface object and clone it.
+ *
+ * @param databaseType the type of DatabaseInterface to look for (description)
+ * @return The requested DatabaseInterface
+ * @throws KettleDatabaseException when the type could not be found or referenced.
+ */
+ public static final DatabaseInterface getDatabaseInterface(String databaseType) throws KettleDatabaseException {
+ DatabaseInterface di = findDatabaseInterface(databaseType);
+ if (di == null) {
+ throw new KettleDatabaseException(BaseMessages.getString(
+ PKG, "DatabaseMeta.Error.DatabaseInterfaceNotFound", databaseType));
+ }
+ return (DatabaseInterface) di.clone();
+ }
+
+ /**
+ * Search for the right type of DatabaseInterface object and return it.
+ *
+ * @param databaseTypeDesc the type of DatabaseInterface to look for (id or description)
+ * @return The requested DatabaseInterface
+ * @throws KettleDatabaseException when the type could not be found or referenced.
+ */
+ private static final DatabaseInterface findDatabaseInterface(String databaseTypeDesc) throws KettleDatabaseException {
+ PluginRegistry registry = PluginRegistry.getInstance();
+ PluginInterface plugin = registry.getPlugin(DatabasePluginType.class, databaseTypeDesc);
+ if (plugin == null) {
+ plugin = registry.findPluginWithName(DatabasePluginType.class, databaseTypeDesc);
+ }
+
+ if (plugin == null) {
+ throw new KettleDatabaseException("database type with plugin id ["
+ + databaseTypeDesc + "] couldn't be found!");
+ }
+
+ return getDatabaseInterfacesMap().get(plugin.getIds()[0]);
+ }
+
+ /**
+ * Returns the database ID of this database connection if a repository was used before.
+ *
+ * @return the ID of the db connection.
+ */
+ @Override
+ public ObjectId getObjectId() {
+ return databaseInterface.getObjectId();
+ }
+
+ @Override
+ public void setObjectId(ObjectId id) {
+ databaseInterface.setObjectId(id);
+ }
+
+ @Override
+ public Object clone() {
+ DatabaseMeta databaseMeta = new DatabaseMeta();
+ databaseMeta.replaceMeta(this);
+ databaseMeta.setObjectId(null);
+ return databaseMeta;
+ }
+
+ public void replaceMeta(DatabaseMeta databaseMeta) {
+ this.setValues(
+ databaseMeta.getName(), databaseMeta.getPluginId(), databaseMeta.getAccessTypeDesc(), databaseMeta
+ .getHostname(), databaseMeta.getDatabaseName(), databaseMeta.getDatabasePortNumberString(),
+ databaseMeta.getUsername(), databaseMeta.getPassword());
+ this.setServername(databaseMeta.getServername());
+ this.setDataTablespace(databaseMeta.getDataTablespace());
+ this.setIndexTablespace(databaseMeta.getIndexTablespace());
+
+ this.databaseInterface = (DatabaseInterface) databaseMeta.databaseInterface.clone();
+
+ this.setObjectId(databaseMeta.getObjectId());
+ this.setChanged();
+ }
+
+ public void setValues(String name, String type, String access, String host, String db, String port,
+ String user, String pass) {
+ try {
+ databaseInterface = getDatabaseInterface(type);
+ } catch (KettleDatabaseException kde) {
+ throw new RuntimeException("Database type not found!", kde);
+ }
+
+ setName(name);
+ setAccessType(getAccessType(access));
+ setHostname(host);
+ setDBName(db);
+ setDBPort(port);
+ setUsername(user);
+ setPassword(pass);
+ setServername(null);
+ setChanged(false);
+ }
+
+ public void setDatabaseType(String type) {
+ DatabaseInterface oldInterface = databaseInterface;
+
+ try {
+ databaseInterface = getDatabaseInterface(type);
+ } catch (KettleDatabaseException kde) {
+ throw new RuntimeException("Database type [" + type + "] not found!", kde);
+ }
+
+ setName(oldInterface.getName());
+ setDisplayName(oldInterface.getDisplayName());
+ setAccessType(oldInterface.getAccessType());
+ setHostname(oldInterface.getHostname());
+ setDBName(oldInterface.getDatabaseName());
+ setDBPort(oldInterface.getDatabasePortNumberString());
+ setUsername(oldInterface.getUsername());
+ setPassword(oldInterface.getPassword());
+ setServername(oldInterface.getServername());
+ setDataTablespace(oldInterface.getDataTablespace());
+ setIndexTablespace(oldInterface.getIndexTablespace());
+ setChanged(oldInterface.isChanged());
+ }
+
+ public void setValues(DatabaseMeta info) {
+ databaseInterface = (DatabaseInterface) info.databaseInterface.clone();
+ }
+
+ /**
+ * Sets the name of the database connection. This name should be unique in a transformation and in general in a single
+ * repository.
+ *
+ * @param name The name of the database connection
+ */
+ @Override
+ public void setName(String name) {
+ databaseInterface.setName(name);
+ }
+
+ /**
+ * Returns the name of the database connection
+ *
+ * @return The name of the database connection
+ */
+ @Override
+ public String getName() {
+ return databaseInterface.getName();
+ }
+
+ public void setDisplayName(String displayName) {
+ databaseInterface.setDisplayName(displayName);
+ }
+
+ /**
+ * Returns the name of the database connection
+ *
+ * @return The name of the database connection
+ */
+ public String getDisplayName() {
+ return databaseInterface.getDisplayName();
+ }
+
+ /**
+ * Returns the type of database, one of
+ *
+ * TYPE_DATABASE_MYSQL
+ *
+ * TYPE_DATABASE_ORACLE
+ *
+ * TYPE_DATABASE_...
+ *
+ *
+ * @return the database type
+ * @Deprecated public int getDatabaseType() { return databaseInterface.getDatabaseType(); }
+ */
+
+ /**
+ * The plugin ID of the database interface
+ */
+ public String getPluginId() {
+ return databaseInterface.getPluginId();
+ }
+
+ /*
+ * Sets the type of database.
+ *
+ * @param db_type The database type public void setDatabaseType(int db_type) { databaseInterface this.databaseType =
+ * db_type; }
+ */
+
+ /**
+ * Return the type of database access. One of
+ *
+ * TYPE_ACCESS_NATIVE
+ *
+ * TYPE_ACCESS_ODBC
+ *
+ * TYPE_ACCESS_OCI
+ *
+ *
+ * @return The type of database access.
+ */
+ public int getAccessType() {
+ return databaseInterface.getAccessType();
+ }
+
+ /**
+ * Set the type of database access.
+ *
+ * @param access_type The access type.
+ */
+ public void setAccessType(int access_type) {
+ databaseInterface.setAccessType(access_type);
+ }
+
+ /**
+ * Returns a short description of the type of database.
+ *
+ * @return A short description of the type of database.
+ * @deprecated This is actually the plugin ID
+ */
+ @Deprecated
+ public String getDatabaseTypeDesc() {
+ return getPluginId();
+ }
+
+ /**
+ * Gets you a short description of the type of database access.
+ *
+ * @return A short description of the type of database access.
+ */
+ public String getAccessTypeDesc() {
+ return dbAccessTypeCode[getAccessType()];
+ }
+
+ /**
+ * Return the hostname of the machine on which the database runs.
+ *
+ * @return The hostname of the database.
+ */
+ public String getHostname() {
+ return databaseInterface.getHostname();
+ }
+
+ /**
+ * Sets the hostname of the machine on which the database runs.
+ *
+ * @param hostname The hostname of the machine on which the database runs.
+ */
+ public void setHostname(String hostname) {
+ databaseInterface.setHostname(hostname);
+ }
+
+ /**
+ * Return the port on which the database listens as a String. Allows for parameterisation.
+ *
+ * @return The database port.
+ */
+ public String getDatabasePortNumberString() {
+ return databaseInterface.getDatabasePortNumberString();
+ }
+
+ /**
+ * Sets the port on which the database listens.
+ *
+ * @param db_port The port number on which the database listens
+ */
+ public void setDBPort(String db_port) {
+ databaseInterface.setDatabasePortNumberString(db_port);
+ }
+
+ /**
+ * Return the name of the database.
+ *
+ * @return The database name.
+ */
+ public String getDatabaseName() {
+ return databaseInterface.getDatabaseName();
+ }
+
+ /**
+ * Set the name of the database.
+ *
+ * @param databaseName The new name of the database
+ */
+ public void setDBName(String databaseName) {
+ databaseInterface.setDatabaseName(databaseName);
+ }
+
+ /**
+ * Get the username to log into the database on this connection.
+ *
+ * @return The username to log into the database on this connection.
+ */
+ public String getUsername() {
+ return databaseInterface.getUsername();
+ }
+
+ /**
+ * Sets the username to log into the database on this connection.
+ *
+ * @param username The username
+ */
+ public void setUsername(String username) {
+ databaseInterface.setUsername(username);
+ }
+
+ /**
+ * Get the password to log into the database on this connection.
+ *
+ * @return the password to log into the database on this connection.
+ */
+ public String getPassword() {
+ return databaseInterface.getPassword();
+ }
+
+ /**
+ * Sets the password to log into the database on this connection.
+ *
+ * @param password the password to log into the database on this connection.
+ */
+ public void setPassword(String password) {
+ databaseInterface.setPassword(password);
+ }
+
+ /**
+ * @param servername the Informix servername
+ */
+ public void setServername(String servername) {
+ databaseInterface.setServername(servername);
+ }
+
+ /**
+ * @return the Informix servername
+ */
+ public String getServername() {
+ return databaseInterface.getServername();
+ }
+
+ public String getDataTablespace() {
+ return databaseInterface.getDataTablespace();
+ }
+
+ public void setDataTablespace(String data_tablespace) {
+ databaseInterface.setDataTablespace(data_tablespace);
+ }
+
+ public String getIndexTablespace() {
+ return databaseInterface.getIndexTablespace();
+ }
+
+ public void setIndexTablespace(String index_tablespace) {
+ databaseInterface.setIndexTablespace(index_tablespace);
+ }
+
+ public void setChanged() {
+ setChanged(true);
+ }
+
+ public void setChanged(boolean ch) {
+ databaseInterface.setChanged(ch);
+ }
+
+ public boolean hasChanged() {
+ return databaseInterface.isChanged();
+ }
+
+ public void clearChanged() {
+ databaseInterface.setChanged(false);
+ }
+
+ @Override
+ public String toString() {
+ return getDisplayName();
+ }
+
+ /**
+ * @return The extra attributes for this database connection
+ */
+ public Properties getAttributes() {
+ return databaseInterface.getAttributes();
+ }
+
+ /**
+ * Set extra attributes on this database connection
+ *
+ * @param attributes The extra attributes to set on this database connection.
+ */
+ public void setAttributes(Properties attributes) {
+ databaseInterface.setAttributes(attributes);
+ }
+
+ /**
+ * Constructs a new database using an XML string snippet. It expects the snippet to be enclosed in
+ * connection
tags.
+ *
+ * @param xml The XML string to parse
+ * @throws KettleXMLException in case there is an XML parsing error
+ */
+ public DatabaseMeta(String xml) throws KettleXMLException {
+ this(XMLHandler.getSubNode(XMLHandler.loadXMLString(xml), "connection"));
+ }
+
+ /**
+ * Reads the information from an XML Node into this new database connection.
+ *
+ * @param con The Node to read the data from
+ * @throws KettleXMLException
+ */
+ public DatabaseMeta(Node con) throws KettleXMLException {
+ this();
+
+ try {
+ String type = XMLHandler.getTagValue(con, "type");
+ try {
+ databaseInterface = getDatabaseInterface(type);
+
+ } catch (KettleDatabaseException kde) {
+ throw new KettleXMLException("Unable to create new database interface", kde);
+ }
+
+ setName(XMLHandler.getTagValue(con, "name"));
+ setDisplayName(getName());
+ setHostname(XMLHandler.getTagValue(con, "server"));
+ String acc = XMLHandler.getTagValue(con, "access");
+ setAccessType(getAccessType(acc));
+
+ setDBName(XMLHandler.getTagValue(con, "database"));
+
+ // The DB port is read here too for backward compatibility! getName()
+ //
+ setDBPort(XMLHandler.getTagValue(con, "port"));
+ setUsername(XMLHandler.getTagValue(con, "username"));
+ setPassword(Encr.decryptPasswordOptionallyEncrypted(XMLHandler.getTagValue(con, "password")));
+ setServername(XMLHandler.getTagValue(con, "servername"));
+ setDataTablespace(XMLHandler.getTagValue(con, "data_tablespace"));
+ setIndexTablespace(XMLHandler.getTagValue(con, "index_tablespace"));
+
+ setReadOnly(Boolean.valueOf(XMLHandler.getTagValue(con, "read_only")));
+
+ // Also, read the database attributes...
+ Node attrsnode = XMLHandler.getSubNode(con, "attributes");
+ if (attrsnode != null) {
+ List attrnodes = XMLHandler.getNodes(attrsnode, "attribute");
+ for (Node attrnode : attrnodes) {
+ String code = XMLHandler.getTagValue(attrnode, "code");
+ String attribute = XMLHandler.getTagValue(attrnode, "attribute");
+ if (code != null && attribute != null) {
+ getAttributes().put(code, attribute);
+ }
+ getDatabasePortNumberString();
+ }
+ }
+ } catch (Exception e) {
+ throw new KettleXMLException("Unable to load database connection info from XML node", e);
+ }
+ }
+
+ @Override
+ public String getXML() {
+ StringBuffer retval = new StringBuffer(250);
+
+ retval.append(" <").append(XML_TAG).append('>').append(Const.CR);
+ retval.append(" ").append(XMLHandler.addTagValue("name", getName()));
+ retval.append(" ").append(XMLHandler.addTagValue("server", getHostname()));
+ retval.append(" ").append(XMLHandler.addTagValue("type", getPluginId()));
+ retval.append(" ").append(XMLHandler.addTagValue("access", getAccessTypeDesc()));
+ retval.append(" ").append(XMLHandler.addTagValue("database", getDatabaseName()));
+ retval.append(" ").append(XMLHandler.addTagValue("port", getDatabasePortNumberString()));
+ retval.append(" ").append(XMLHandler.addTagValue("username", getUsername()));
+ retval.append(" ").append(
+ XMLHandler.addTagValue("password", Encr.encryptPasswordIfNotUsingVariables(getPassword())));
+ retval.append(" ").append(XMLHandler.addTagValue("servername", getServername()));
+ retval.append(" ").append(XMLHandler.addTagValue("data_tablespace", getDataTablespace()));
+ retval.append(" ").append(XMLHandler.addTagValue("index_tablespace", getIndexTablespace()));
+
+ // only write the tag out if it is set to true
+ if (isReadOnly()) {
+ retval.append(" ").append(XMLHandler.addTagValue("read_only", Boolean.toString(isReadOnly())));
+ }
+
+ retval.append(" ").append(Const.CR);
+
+ List list = new ArrayList();
+ Set").append(Const.CR);
+
+ retval.append(" " + XML_TAG + ">").append(Const.CR);
+ return retval.toString();
+ }
+
+ @Override
+ public int hashCode() {
+ return getName().hashCode(); // name of connection is unique!
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return obj instanceof DatabaseMeta && getName().equals(((DatabaseMeta) obj).getName());
+ }
+
+ public String getURL() throws KettleDatabaseException {
+ return getURL(null);
+ }
+
+ public String getURL(String partitionId) throws KettleDatabaseException {
+ // First see if we're not doing any JNDI...
+ //
+ /*
+ * This doesn't make much sense here - we check but do nothing? if ( getAccessType() == TYPE_ACCESS_JNDI ) { // We
+ * can't really determine the URL here. // // }
+ */
+ String baseUrl;
+ String hostname;
+ String port;
+ String databaseName;
+
+ if (isPartitioned() && !Const.isEmpty(partitionId)) {
+ // Get the cluster information...
+ PartitionDatabaseMeta partition = getPartitionMeta(partitionId);
+ hostname = environmentSubstitute(partition.getHostname());
+ port = environmentSubstitute(partition.getPort());
+ databaseName = environmentSubstitute(partition.getDatabaseName());
+ } else {
+ hostname = environmentSubstitute(getHostname());
+ port = environmentSubstitute(getDatabasePortNumberString());
+ databaseName = environmentSubstitute(getDatabaseName());
+ }
+ baseUrl = databaseInterface.getURL(environmentSubstitute(hostname), environmentSubstitute(port),
+ environmentSubstitute(databaseName));
+ StringBuffer url = new StringBuffer(environmentSubstitute(baseUrl));
+
+ if (databaseInterface.supportsOptionsInURL()) {
+ // OK, now add all the options...
+ String optionIndicator = getExtraOptionIndicator();
+ String optionSeparator = getExtraOptionSeparator();
+ String valueSeparator = getExtraOptionValueSeparator();
+
+ Map map = getExtraOptions();
+ if (map.size() > 0) {
+ Iterator iterator = map.keySet().iterator();
+ boolean first = true;
+ while (iterator.hasNext()) {
+ String typedParameter = iterator.next();
+ int dotIndex = typedParameter.indexOf('.');
+ if (dotIndex >= 0) {
+ String typeCode = typedParameter.substring(0, dotIndex);
+ String parameter = typedParameter.substring(dotIndex + 1);
+ String value = map.get(typedParameter);
+
+ // Only add to the URL if it's the same database type code...
+ //
+ if (databaseInterface.getPluginId().equals(typeCode)) {
+ if (first && url.indexOf(valueSeparator) == -1) {
+ url.append(optionIndicator);
+ } else {
+ url.append(optionSeparator);
+ }
+
+ url.append(parameter);
+ if (!Const.isEmpty(value) && !value.equals(EMPTY_OPTIONS_STRING)) {
+ url.append(valueSeparator).append(value);
+ }
+ first = false;
+ }
+ }
+ }
+ }
+ }
+ // else {
+ // We need to put all these options in a Properties file later (Oracle & Co.)
+ // This happens at connect time...
+ // }
+
+ return url.toString();
+ }
+
+ public Properties getConnectionProperties() {
+ Properties properties = new Properties();
+
+ Map map = getExtraOptions();
+ if (map.size() > 0) {
+ Iterator iterator = map.keySet().iterator();
+ while (iterator.hasNext()) {
+ String typedParameter = iterator.next();
+ int dotIndex = typedParameter.indexOf('.');
+ if (dotIndex >= 0) {
+ String typeCode = typedParameter.substring(0, dotIndex);
+ String parameter = typedParameter.substring(dotIndex + 1);
+ String value = map.get(typedParameter);
+
+ // Only add to the URL if it's the same database type code...
+ //
+ if (databaseInterface.getPluginId().equals(typeCode)) {
+ if (value != null && value.equals(EMPTY_OPTIONS_STRING)) {
+ value = "";
+ }
+ properties.put(parameter, environmentSubstitute(Const.NVL(value, "")));
+ }
+ }
+ }
+ }
+
+ return properties;
+ }
+
+ public String getExtraOptionIndicator() {
+ return databaseInterface.getExtraOptionIndicator();
+ }
+
+ /**
+ * @return The extra option separator in database URL for this platform (usually this is semicolon ; )
+ */
+ public String getExtraOptionSeparator() {
+ return databaseInterface.getExtraOptionSeparator();
+ }
+
+ /**
+ * @return The extra option value separator in database URL for this platform (usually this is the equal sign = )
+ */
+ public String getExtraOptionValueSeparator() {
+ return databaseInterface.getExtraOptionValueSeparator();
+ }
+
+ /**
+ * Add an extra option to the attributes list
+ *
+ * @param databaseTypeCode The database type code for which the option applies
+ * @param option The option to set
+ * @param value The value of the option
+ */
+ public void addExtraOption(String databaseTypeCode, String option, String value) {
+ databaseInterface.addExtraOption(databaseTypeCode, option, value);
+ }
+
+ public void applyDefaultOptions(DatabaseInterface databaseInterface) {
+ final Map extraOptions = getExtraOptions();
+
+ final Map defaultOptions = databaseInterface.getDefaultOptions();
+ for (String option : defaultOptions.keySet()) {
+ String value = defaultOptions.get(option);
+ String[] split = option.split("[.]", 2);
+ if (!extraOptions.containsKey(option) && split.length == 2) {
+ addExtraOption(split[0], split[1], value);
+ }
+ }
+ }
+
+ /**
+ * @return true if the database supports transactions
+ * @deprecated because the same database can support transactions or not. It all depends on the database setup.
+ * Therefor, we look at the database metadata DatabaseMetaData.supportsTransactions() in stead of this.
+ */
+ @Deprecated
+ public boolean supportsTransactions() {
+ return databaseInterface.supportsTransactions();
+ }
+
+ public boolean supportsAutoinc() {
+ return databaseInterface.supportsAutoInc();
+ }
+
+ public boolean supportsSequences() {
+ return databaseInterface.supportsSequences();
+ }
+
+ public String getSQLSequenceExists(String sequenceName) {
+ return databaseInterface.getSQLSequenceExists(sequenceName);
+ }
+
+ public boolean supportsBitmapIndex() {
+ return databaseInterface.supportsBitmapIndex();
+ }
+
+ public boolean supportsSetLong() {
+ return databaseInterface.supportsSetLong();
+ }
+
+ /**
+ * @return true if the database supports schemas
+ */
+ public boolean supportsSchemas() {
+ return databaseInterface.supportsSchemas();
+ }
+
+ /**
+ * @return true if the database supports catalogs
+ */
+ public boolean supportsCatalogs() {
+ return databaseInterface.supportsCatalogs();
+ }
+
+ /**
+ * @return true when the database engine supports empty transaction. (for example Informix does not on a non-ANSI
+ * database type!)
+ */
+ public boolean supportsEmptyTransactions() {
+ return databaseInterface.supportsEmptyTransactions();
+ }
+
+ /**
+ * See if this database supports the setCharacterStream() method on a PreparedStatement.
+ *
+ * @return true if we can set a Stream on a field in a PreparedStatement. False if not.
+ */
+ public boolean supportsSetCharacterStream() {
+ return databaseInterface.supportsSetCharacterStream();
+ }
+
+ /**
+ * Get the maximum length of a text field for this database connection. This includes optional CLOB, Memo and Text
+ * fields. (the maximum!)
+ *
+ * @return The maximum text field length for this database type. (mostly CLOB_LENGTH)
+ */
+ public int getMaxTextFieldLength() {
+ return databaseInterface.getMaxTextFieldLength();
+ }
+
+ public static final int getAccessType(String dbaccess) {
+ int i;
+
+ if (dbaccess == null) {
+ return TYPE_ACCESS_NATIVE;
+ }
+
+ for (i = 0; i < dbAccessTypeCode.length; i++) {
+ if (dbAccessTypeCode[i].equalsIgnoreCase(dbaccess)) {
+ return i;
+ }
+ }
+ for (i = 0; i < dbAccessTypeDesc.length; i++) {
+ if (dbAccessTypeDesc[i].equalsIgnoreCase(dbaccess)) {
+ return i;
+ }
+ }
+
+ return TYPE_ACCESS_NATIVE;
+ }
+
+ public static final String getAccessTypeDesc(int dbaccess) {
+ if (dbaccess < 0) {
+ return null;
+ }
+ if (dbaccess > dbAccessTypeCode.length) {
+ return null;
+ }
+
+ return dbAccessTypeCode[dbaccess];
+ }
+
+ public static final String getAccessTypeDescLong(int dbaccess) {
+ if (dbaccess < 0) {
+ return null;
+ }
+ if (dbaccess > dbAccessTypeDesc.length) {
+ return null;
+ }
+
+ return dbAccessTypeDesc[dbaccess];
+ }
+
+ public static final DatabaseInterface[] getDatabaseInterfaces() {
+ List list = new ArrayList(getDatabaseInterfacesMap().values());
+ return list.toArray(new DatabaseInterface[list.size()]);
+ }
+
+ /**
+ * Clear the database interfaces map. The map is cached by getDatabaseInterfacesMap(), but in some instances it may
+ * need to be reloaded (such as adding/updating Database plugins). After calling clearDatabaseInterfacesMap(), the
+ * next call to getDatabaseInterfacesMap() will reload the map.
+ */
+ public static final void clearDatabaseInterfacesMap() {
+ allDatabaseInterfaces = null;
+ }
+
+ private static final Future