Package com.github.kopylec.rapidjdbc.exception

Examples of com.github.kopylec.rapidjdbc.exception.RapidJDBCException


    <E> E initializeEntity(Class<E> entityClass) throws RapidJDBCException {
        LOGGER.trace("Initializing entity of class {}", entityClass.getName());

        if (!entityFieldsByClass.containsKey(entityClass)) {
            throw new RapidJDBCException("Class (" + entityClass.getName() + ") has not been added to contexts entity classes");
        }
        try {
            return entityClass.newInstance();
        } catch (IllegalAccessException ex) {
            throw new RapidJDBCException("Error initializing entity of class " + entityClass.getName(), ex);
        } catch (InstantiationException ex) {
            throw new RapidJDBCException("Error initializing entity of class " + entityClass.getName(), ex);
        }
    }
View Full Code Here


            LOGGER.debug("Closing active database connection");
            try {
                connection.get().close();
                connection.remove();
            } catch (SQLException ex) {
                throw new RapidJDBCException("Error closing database connection", ex);
            }
        }
    }
View Full Code Here

            connection.get().setAutoCommit(false);
            if (level != TransactionLevel.DEFAULT) {
                connection.get().setTransactionIsolation(level.getLevel());
            }
        } catch (SQLException ex) {
            throw new RapidJDBCException("Error beginning JDBC transaction", ex);
        }
    }
View Full Code Here

        if (connection.get() != null) {
            LOGGER.debug("Committing JDBC transaction");
            try {
                connection.get().commit();
            } catch (SQLException ex) {
                throw new RapidJDBCException("Error committing JDBC transaction", ex);
            } finally {
                enableAutoCommit();
            }
        }
    }
View Full Code Here

        if (connection.get() != null) {
            LOGGER.debug("Rollbacking JDBC transaction");
            try {
                connection.get().rollback();
            } catch (SQLException ex) {
                throw new RapidJDBCException("Error rollbacking JDBC transaction", ex);
            } finally {
                enableAutoCommit();
            }
        }
    }
View Full Code Here

     */
    public final void setDataSource(DataSource dataSource) throws RapidJDBCException {
        LOGGER.debug("Setting data source");

        if (dataSource == null) {
            throw new RapidJDBCException("Data source is null");
        }
        if (this.dataSource != null) {
            throw new RapidJDBCException("Data source already set");
        }
        this.dataSource = dataSource;
    }
View Full Code Here

        if (connection.get() != null) {
            try {
                LOGGER.trace("Checking if JDBC transaction is active");
                return !connection.get().getAutoCommit();
            } catch (SQLException ex) {
                throw new RapidJDBCException("Error checking if JDBC transaction is active", ex);
            }
        }
        return false;
    }
View Full Code Here

     */
    public final void setEntityClasses(Class... classes) throws RapidJDBCException {
        LOGGER.debug("Setting entity classes: {}", Arrays.toString(classes));

        if (classes == null) {
            throw new RapidJDBCException("Entity classes are null");
        }
        if (!entityFieldsByClass.isEmpty()) {
            throw new RapidJDBCException("Entity classes already set");
        }
        for (Class clazz : classes) {
            if (clazz != null) {
                addEntityFieldsByClass(clazz);
            }
View Full Code Here

        LOGGER.debug("Creating connection from data source");

        try {
            connection.set(dataSource.getConnection());
        } catch (SQLException ex) {
            throw new RapidJDBCException("Error creating connection to database", ex);
        }
    }
View Full Code Here

        if (connection.get() != null) {
            LOGGER.trace("Enabling auto commit on database connection");
            try {
                connection.get().setAutoCommit(true);
            } catch (SQLException ex) {
                throw new RapidJDBCException("Error enabling auto commit", ex);
            }
        }
    }
View Full Code Here

TOP

Related Classes of com.github.kopylec.rapidjdbc.exception.RapidJDBCException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.