Search in sources :

Example 91 with KettleDatabaseException

use of org.pentaho.di.core.exception.KettleDatabaseException in project pentaho-kettle by pentaho.

the class DatabaseJoinMeta method getTableFields.

@Override
public RowMetaInterface getTableFields() {
    // Build a dummy parameter row...
    // 
    RowMetaInterface param = new RowMeta();
    for (int i = 0; i < parameterField.length; i++) {
        ValueMetaInterface v;
        try {
            v = ValueMetaFactory.createValueMeta(parameterField[i], parameterType[i]);
        } catch (KettlePluginException e) {
            v = new ValueMetaNone(parameterField[i]);
        }
        param.addValueMeta(v);
    }
    RowMetaInterface fields = null;
    if (databaseMeta != null) {
        Database db = new Database(loggingObject, databaseMeta);
        // Keep track of this one for cancelQuery
        databases = new Database[] { db };
        try {
            db.connect();
            fields = db.getQueryFields(databaseMeta.environmentSubstitute(sql), true, param, new Object[param.size()]);
        } catch (KettleDatabaseException dbe) {
            logError(BaseMessages.getString(PKG, "DatabaseJoinMeta.Log.DatabaseErrorOccurred") + dbe.getMessage());
        } finally {
            db.disconnect();
        }
    }
    return fields;
}
Also used : KettlePluginException(org.pentaho.di.core.exception.KettlePluginException) ValueMetaNone(org.pentaho.di.core.row.value.ValueMetaNone) RowMeta(org.pentaho.di.core.row.RowMeta) KettleDatabaseException(org.pentaho.di.core.exception.KettleDatabaseException) Database(org.pentaho.di.core.database.Database) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface)

Example 92 with KettleDatabaseException

use of org.pentaho.di.core.exception.KettleDatabaseException in project pentaho-kettle by pentaho.

the class RepositoryDirectoryUI method loadRepositoryObjects.

protected static List<RepositoryElementMetaInterface> loadRepositoryObjects(RepositoryDirectoryInterface dir, boolean getTransformations, boolean getJobs, Repository rep) throws KettleDatabaseException {
    // Then show the transformations & jobs in that directory...
    List<RepositoryElementMetaInterface> repositoryObjects = new ArrayList<RepositoryElementMetaInterface>();
    if (dir.getRepositoryObjects() == null) {
        try {
            dir.setRepositoryObjects(rep.getJobAndTransformationObjects(dir.getObjectId(), false));
        } catch (KettleException e) {
            throw new KettleDatabaseException(e);
        }
    }
    List<RepositoryObjectType> allowedTypes = new ArrayList<>(2);
    if (getTransformations) {
        allowedTypes.add(RepositoryObjectType.TRANSFORMATION);
    }
    if (getJobs) {
        allowedTypes.add(RepositoryObjectType.JOB);
    }
    for (RepositoryElementMetaInterface repoObject : dir.getRepositoryObjects()) {
        if (allowedTypes.contains(repoObject.getObjectType())) {
            repositoryObjects.add(repoObject);
        }
    }
    return repositoryObjects;
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) KettleDatabaseException(org.pentaho.di.core.exception.KettleDatabaseException) ArrayList(java.util.ArrayList) RepositoryObjectType(org.pentaho.di.repository.RepositoryObjectType) RepositoryElementMetaInterface(org.pentaho.di.repository.RepositoryElementMetaInterface)

Example 93 with KettleDatabaseException

use of org.pentaho.di.core.exception.KettleDatabaseException in project pentaho-kettle by pentaho.

the class JobEntryMysqlBulkFileDialog method getListColumns.

/**
 * Get a list of columns, comma separated, allow the user to select from it.
 */
private void getListColumns() {
    if (!Utils.isEmpty(wTablename.getText())) {
        DatabaseMeta databaseMeta = jobMeta.findDatabase(wConnection.getText());
        if (databaseMeta != null) {
            Database database = new Database(loggingObject, databaseMeta);
            database.shareVariablesWith(jobMeta);
            try {
                database.connect();
                String schemaTable = databaseMeta.getQuotedSchemaTableCombination(wSchemaname.getText(), wTablename.getText());
                RowMetaInterface row = database.getTableFields(schemaTable);
                String[] available = row.getFieldNames();
                String[] source = wListColumn.getText().split(",");
                for (int i = 0; i < source.length; i++) {
                    source[i] = Const.trim(source[i]);
                }
                int[] idxSource = Const.indexsOfStrings(source, available);
                EnterSelectionDialog dialog = new EnterSelectionDialog(shell, available, BaseMessages.getString(PKG, "JobMysqlBulkFile.SelectColumns.Title"), BaseMessages.getString(PKG, "JobMysqlBulkFile.SelectColumns.Message"));
                dialog.setMulti(true);
                dialog.setAvoidQuickSearch();
                dialog.setSelectedNrs(idxSource);
                if (dialog.open() != null) {
                    String columns = "";
                    int[] idx = dialog.getSelectionIndeces();
                    for (int i = 0; i < idx.length; i++) {
                        if (i > 0) {
                            columns += ", ";
                        }
                        columns += available[idx[i]];
                    }
                    wListColumn.setText(columns);
                }
            } catch (KettleDatabaseException e) {
                new ErrorDialog(shell, BaseMessages.getString(PKG, "System.Dialog.Error.Title"), BaseMessages.getString(PKG, "JobMysqlBulkFile.ConnectionError2.DialogMessage"), e);
            } finally {
                database.disconnect();
            }
        }
    }
}
Also used : KettleDatabaseException(org.pentaho.di.core.exception.KettleDatabaseException) Database(org.pentaho.di.core.database.Database) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) EnterSelectionDialog(org.pentaho.di.ui.core.dialog.EnterSelectionDialog)

Example 94 with KettleDatabaseException

use of org.pentaho.di.core.exception.KettleDatabaseException in project pentaho-kettle by pentaho.

the class PaloCubeCreate method saveRep.

public void saveRep(Repository rep, IMetaStore metaStore, ObjectId id_job) throws KettleException {
    try {
        rep.saveDatabaseMetaJobEntryAttribute(id_job, getObjectId(), "connection", "id_database", databaseMeta);
        rep.saveJobEntryAttribute(id_job, getObjectId(), "cubeName", this.getCubeName());
        for (int i = 0; i < this.dimensionNames.size(); i++) {
            rep.saveJobEntryAttribute(id_job, getObjectId(), i, "dimensionname", this.dimensionNames.get(i));
        }
    } catch (KettleDatabaseException dbe) {
        throw new KettleException("unable to save jobentry of type 'file exists' to the repository for id_job=" + id_job, dbe);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) KettleDatabaseException(org.pentaho.di.core.exception.KettleDatabaseException)

Example 95 with KettleDatabaseException

use of org.pentaho.di.core.exception.KettleDatabaseException in project pentaho-kettle by pentaho.

the class PaloCubeDelete method saveRep.

public void saveRep(Repository rep, IMetaStore metaStore, ObjectId id_job) throws KettleException {
    try {
        rep.saveDatabaseMetaJobEntryAttribute(id_job, getObjectId(), "connection", "id_database", databaseMeta);
        rep.saveStepAttribute(id_job, getObjectId(), "cubeName", this.getCubeName());
    } catch (KettleDatabaseException dbe) {
        throw new KettleException("unable to save jobentry of type 'file exists' to the repository for id_job=" + id_job, dbe);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) KettleDatabaseException(org.pentaho.di.core.exception.KettleDatabaseException)

Aggregations

KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)279 KettleException (org.pentaho.di.core.exception.KettleException)176 SQLException (java.sql.SQLException)69 Database (org.pentaho.di.core.database.Database)46 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)41 KettleValueException (org.pentaho.di.core.exception.KettleValueException)39 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)37 KettleDatabaseBatchException (org.pentaho.di.core.exception.KettleDatabaseBatchException)33 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)31 BatchUpdateException (java.sql.BatchUpdateException)27 ResultSet (java.sql.ResultSet)27 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)26 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)25 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)24 RowMeta (org.pentaho.di.core.row.RowMeta)22 FileObject (org.apache.commons.vfs2.FileObject)18 LongObjectId (org.pentaho.di.repository.LongObjectId)17 Savepoint (java.sql.Savepoint)16 ArrayList (java.util.ArrayList)16 Test (org.junit.Test)14