Package org.rhq.core.db

Examples of org.rhq.core.db.ExtendedSQLException


                    dropDB = connection.createStatement();
                    String dropSql = "drop database if exists " + dbName;
                    try {                   
                        dropDB.execute(dropSql);
                    } catch (SQLException e) {
                        throw new ExtendedSQLException(e, dropSql);
                    }
   
                    createDB = connection.createStatement();
                    String createSql = "create database " + dbName + " with owner " + user;
                    try {
                        createDB.execute(createSql);
                    } catch (SQLException e) {
                        throw new ExtendedSQLException(e, createSql);
                    }
   
                    log.info("Dropped and created postgres database " + dbName + ".");
                } finally {
                    if (dropDB != null) {
                        dropDB.close();
                    }
                    if (createDB != null) {
                        createDB.close();
                    }
                    if (connection != null) {
                        connection.close();
                    }
                }
            } else if (dbTypeMapping.equals("Oracle10g")) {
                Connection connection = null;
                PreparedStatement cleanUserStatement = null;
   
                try {
                    connection = DbUtil.getConnection(dbUrl, adminUser, adminPassword);
                    connection.setAutoCommit(false);
   
                    String plsql = "declare cursor all_objects_to_drop is\n"
                        + "select *  from user_objects where object_type in ('TABLE', 'VIEW', 'FUNCTION', 'SEQUENCE');\n"
                        + "begin\n"
                        + "  for obj in all_objects_to_drop loop\n"
                        + "    begin\n"
                        + "      if obj.object_type = 'TABLE' then\n"
                        + "        execute immediate('DROP '||obj.object_type||' '||obj.object_name||' CASCADE CONSTRAINTS PURGE');\n"
                        + "      else\n"
                        + "        execute immediate('DROP '||obj.object_type||' '||obj.object_name);\n"
                        + "      end if;\n"
                        + "      exception when others then null;\n"
                        + "    end;\n"
                        + "  end loop;\n"
                        + " end;\n";
                    try {
                        cleanUserStatement = connection.prepareStatement(plsql);
                    } catch (SQLException e) {
                        throw new ExtendedSQLException(e, plsql);
                    }
                    cleanUserStatement.execute();
                    connection.commit();
   
                    log.info("Cleaned Oracle database " + dbName + ".");
View Full Code Here


                    this.getConnection().rollback();
                } catch (Exception e2) {
                    // Log this?
                }

                throw new ExtendedSQLException(e, sql);
            } finally {
                if (stmt != null) {
                    stmt.close();
                }
            }
View Full Code Here

TOP

Related Classes of org.rhq.core.db.ExtendedSQLException

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.