Package net.sourceforge.jivalo.cnfmgr.persistent

Examples of net.sourceforge.jivalo.cnfmgr.persistent.PersistentStorageException


           
            return ds.getConnection();
        }
        catch ( NamingException e )
        {
            throw new PersistentStorageException(getClass().getName(),
                    "Can't find DataSource "+ resourceName
                    + " Reason:"+e.getMessage(), e);
        }
        catch ( SQLException e )
        {
            throw new PersistentStorageException(getClass().getName(),
                    "Can't get connection from DataSource "+ resourceName
                    + " Reason:"+e.getMessage(), e);
        }
    }
View Full Code Here


    private Object executeSql(String sqlString,
                              PreparedStatementParameter[] parameters,
                              String resourceName, boolean isSelect) throws
        BaseException {
        if (sqlString == null) {
            throw new PersistentStorageException(getClass().getName(),
                                                 "SQL is null");
        }

        if (resourceName == null) {
            throw new PersistentStorageException(getClass().getName(),
                                                 "Resource name is null");
        }

        Connection con = getSqlConnection(resourceName);
        if (con == null) {
            throw new PersistentStorageException(getClass().getName(),
                "Connection is not available: " + resourceName);
        }

        PreparedStatement pstmt = null;
        ResultSet rs = null;
        try {
            pstmt = con.prepareStatement(sqlString);

            if (parameters != null) {
                for (int i = 0; i < parameters.length; i++) {
                    int type = parameters[i].getType();
                    Object value = parameters[i].getValue();

                    if (value != null) {
                      pstmt.setObject(i + 1, value);
                    }
                    else {
                      pstmt.setNull(i + 1, parameters[i].getType());
                    }
                }
            }

            if (isSelect) {
                rs = pstmt.executeQuery();
                ResultSetMetaData data = rs.getMetaData();
                int count = data.getColumnCount();
                Vector v = new Vector();
                while (rs.next()) {
                    PreparedStatementResult result = new
                        PreparedStatementResult();
                    for (int i = 1; i < count + 1; i++) {
                        Object value = rs.getObject(i);
                        result.add(data.getColumnName(i), value);
                    }
                    v.add(result);
                }

                return v;
            }
            return new Integer(pstmt.executeUpdate());
        }
        catch (SQLException e) {
            throw new PersistentStorageException(getClass().getName(),
                                                 "Exception executing query", e);
        }
        finally {
            try {
                if (rs != null) {
View Full Code Here

    public Connection getSqlConnection(String resourceName) throws
        BaseException {
        init();
        if (service == null) {
            throw new PersistentStorageException(getClass().getName(),
                "Connection service doesn't exist");
        }

        return service.getConnection(resourceName);
    }
View Full Code Here

    public void refreshDataSources() throws
    BaseException {
      service = null;
        init();
        if (service == null) {
            throw new PersistentStorageException(getClass().getName(),
                "Connection service doesn't exist");
        }
    }
View Full Code Here

    public String getDatabaseType(String resourceName) throws
    BaseException {
        init();
        if (service == null) {
            throw new PersistentStorageException(getClass().getName(),
                "Connection service doesn't exist");
        }

        return service.getDatabaseType(resourceName);
    }
View Full Code Here

TOP

Related Classes of net.sourceforge.jivalo.cnfmgr.persistent.PersistentStorageException

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.