Search in sources :

Example 11 with JdbcException

use of nl.nn.adapterframework.jdbc.JdbcException in project iaf by ibissource.

the class Migrator method configure.

public synchronized void configure(String configurationName, ClassLoader classLoader, String changeLogFile) throws ConfigurationException {
    if (configurationName == null)
        throw new ConfigurationException("configurationName cannot be null");
    AppConstants appConstants = AppConstants.getInstance(classLoader);
    if (changeLogFile == null)
        changeLogFile = appConstants.getString("liquibase.changeLogFile", "DatabaseChangelog.xml");
    LiquibaseClassLoader cl = new LiquibaseClassLoader(classLoader);
    if (cl.getResource(changeLogFile) == null) {
        log.debug("unable to find database changelog file [" + changeLogFile + "] configuration [" + configurationName + "]");
    } else {
        String dataSource = appConstants.getString("jdbc.migrator.dataSource", "jdbc/" + appConstants.getResolvedProperty("instance.name.lc"));
        setDatasourceName(dataSource);
        try {
            JdbcConnection connection = new JdbcConnection(getConnection());
            instance = new LiquibaseImpl(ibisContext, cl, connection, configurationName, changeLogFile);
        } catch (JdbcException e) {
            throw new ConfigurationException("migrator error connecting to database [" + dataSource + "]", e);
        } catch (ValidationFailedException e) {
            throw new ConfigurationException("liquibase validation failed", e);
        } catch (LiquibaseException e) {
            throw new ConfigurationException("liquibase failed to initialize", e);
        }
    }
}
Also used : ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) ValidationFailedException(liquibase.exception.ValidationFailedException) JdbcConnection(liquibase.database.jvm.JdbcConnection) LiquibaseException(liquibase.exception.LiquibaseException) JdbcException(nl.nn.adapterframework.jdbc.JdbcException) AppConstants(nl.nn.adapterframework.util.AppConstants)

Example 12 with JdbcException

use of nl.nn.adapterframework.jdbc.JdbcException in project iaf by ibissource.

the class DomainTransformerPipe method configure.

public void configure() throws ConfigurationException {
    super.configure();
    IbisContext ibisContext = getAdapter().getConfiguration().getIbisManager().getIbisContext();
    qs = (FixedQuerySender) ibisContext.createBeanAutowireByName(FixedQuerySender.class);
    qs.setProxiedDataSources(proxiedDataSources);
    qs.setJmsRealm(jmsRealm);
    // dummy query required
    qs.setQuery("SELECT count(*) FROM ALL_TABLES");
    qs.configure();
    Connection conn = null;
    try {
        conn = qs.getConnection();
        if (!JdbcUtil.columnExists(conn, tableName, "*")) {
            throw new ConfigurationException("The table [" + tableName + "] doesn't exist");
        }
        if (!JdbcUtil.columnExists(conn, tableName, labelField)) {
            throw new ConfigurationException("The column [" + labelField + "] doesn't exist");
        }
        if (!JdbcUtil.columnExists(conn, tableName, valueInField)) {
            throw new ConfigurationException("The column [" + valueInField + "] doesn't exist");
        }
        if (!JdbcUtil.columnExists(conn, tableName, valueOutField)) {
            throw new ConfigurationException("The column [" + valueOutField + "] doesn't exist");
        }
        query = "SELECT " + valueOutField + " FROM " + tableName + " WHERE " + labelField + "=? AND " + valueInField + "=?";
    } catch (JdbcException e) {
        throw new ConfigurationException(e);
    } catch (SQLException e) {
        throw new ConfigurationException(e);
    } finally {
        JdbcUtil.close(conn);
    }
}
Also used : IbisContext(nl.nn.adapterframework.configuration.IbisContext) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) SQLException(java.sql.SQLException) Connection(java.sql.Connection) JdbcException(nl.nn.adapterframework.jdbc.JdbcException)

Example 13 with JdbcException

use of nl.nn.adapterframework.jdbc.JdbcException in project iaf by ibissource.

the class WebSphereMsSqlServerDbmsSupport method updateBlob.

public void updateBlob(ResultSet rs, int column, Object blobUpdateHandle) throws SQLException, JdbcException {
    File blobFile = (File) blobUpdateHandle;
    try {
        InputStream is = new FileInputStream(blobFile);
        rs.updateBinaryStream(column, is, (int) blobFile.length());
    } catch (FileNotFoundException e) {
        throw new JdbcException("cannot read blob for column [" + column + "] from file [" + blobFile.toString() + "]", e);
    }
}
Also used : FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) FileNotFoundException(java.io.FileNotFoundException) File(java.io.File) JdbcException(nl.nn.adapterframework.jdbc.JdbcException) FileInputStream(java.io.FileInputStream)

Example 14 with JdbcException

use of nl.nn.adapterframework.jdbc.JdbcException in project iaf by ibissource.

the class WebSphereMsSqlServerDbmsSupport method updateClob.

public void updateClob(ResultSet rs, int column, Object clobUpdateHandle) throws SQLException, JdbcException {
    File clobFile = (File) clobUpdateHandle;
    try {
        InputStream is = new FileInputStream(clobFile);
        InputStreamReader isr = new InputStreamReader(is, StreamUtil.DEFAULT_INPUT_STREAM_ENCODING);
        // FIXME: should use character count instead of byte count!
        rs.updateCharacterStream(column, isr, (int) clobFile.length());
    } catch (Exception e) {
        throw new JdbcException("cannot read clob for column [" + column + "] from file [" + clobFile.toString() + "]", e);
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) File(java.io.File) JdbcException(nl.nn.adapterframework.jdbc.JdbcException) FileInputStream(java.io.FileInputStream) JdbcException(nl.nn.adapterframework.jdbc.JdbcException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) SQLException(java.sql.SQLException)

Example 15 with JdbcException

use of nl.nn.adapterframework.jdbc.JdbcException in project iaf by ibissource.

the class WebSphereMsSqlServerDbmsSupport method updateClob.

public void updateClob(ResultSet rs, String column, Object clobUpdateHandle) throws SQLException, JdbcException {
    File clobFile = (File) clobUpdateHandle;
    try {
        InputStream is = new FileInputStream(clobFile);
        InputStreamReader isr = new InputStreamReader(is, StreamUtil.DEFAULT_INPUT_STREAM_ENCODING);
        // FIXME: should use character count instead of byte count!
        rs.updateCharacterStream(column, isr, (int) clobFile.length());
    } catch (Exception e) {
        throw new JdbcException("cannot read clob for column [" + column + "] from file [" + clobFile.toString() + "]", e);
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) File(java.io.File) JdbcException(nl.nn.adapterframework.jdbc.JdbcException) FileInputStream(java.io.FileInputStream) JdbcException(nl.nn.adapterframework.jdbc.JdbcException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) SQLException(java.sql.SQLException)

Aggregations

JdbcException (nl.nn.adapterframework.jdbc.JdbcException)26 SQLException (java.sql.SQLException)19 IOException (java.io.IOException)15 PreparedStatement (java.sql.PreparedStatement)13 ResultSet (java.sql.ResultSet)9 JMSException (javax.jms.JMSException)9 DataFormatException (java.util.zip.DataFormatException)8 Connection (java.sql.Connection)7 InputStream (java.io.InputStream)6 SenderException (nl.nn.adapterframework.core.SenderException)6 FileNotFoundException (java.io.FileNotFoundException)5 File (java.io.File)4 FileInputStream (java.io.FileInputStream)4 ConfigurationException (nl.nn.adapterframework.configuration.ConfigurationException)4 InputStreamReader (java.io.InputStreamReader)3 TransformerConfigurationException (javax.xml.transform.TransformerConfigurationException)3 FixedQuerySender (nl.nn.adapterframework.jdbc.FixedQuerySender)3 JmsException (nl.nn.adapterframework.jms.JmsException)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2