Package org.apache.ddlutils

Examples of org.apache.ddlutils.DatabaseOperationException


        {
            int slashPos = connectionUrl.lastIndexOf('/');

            if (slashPos < 0)
            {
                throw new DatabaseOperationException("Cannot parse the given connection url "+connectionUrl);
            }

            int          paramPos   = connectionUrl.lastIndexOf('?');
            String       baseDb     = connectionUrl.substring(0, slashPos + 1) + "template1";
            String       dbName     = (paramPos > slashPos ? connectionUrl.substring(slashPos + 1, paramPos) : connectionUrl.substring(slashPos + 1));
            Connection   connection = null;
            Statement    stmt       = null;
            StringBuffer sql        = new StringBuffer();

            sql.append(createDb ? "CREATE" : "DROP");
            sql.append(" DATABASE ");
            sql.append(dbName);
            if ((parameters != null) && !parameters.isEmpty())
            {
                for (Iterator it = parameters.entrySet().iterator(); it.hasNext();)
                {
                    Map.Entry entry = (Map.Entry)it.next();

                    sql.append(" ");
                    sql.append(entry.getKey().toString());
                    if (entry.getValue() != null)
                    {
                        sql.append(" ");
                        sql.append(entry.getValue().toString());
                    }
                }
            }
            if (getLog().isDebugEnabled())
            {
                getLog().debug("About to create database via "+baseDb+" using this SQL: "+sql.toString());
            }
            try
            {
                Class.forName(jdbcDriverClassName);

                connection = DriverManager.getConnection(baseDb, username, password);
                stmt       = connection.createStatement();
                stmt.execute(sql.toString());
                logWarnings(connection);
            }
            catch (Exception ex)
            {
                throw new DatabaseOperationException("Error while trying to " + (createDb ? "create" : "drop") + " a database: "+ex.getLocalizedMessage(), ex);
            }
            finally
            {
                if (stmt != null)
                {
View Full Code Here


            }
            return connection;
        }
        catch (SQLException ex)
        {
            throw new DatabaseOperationException("Could not get a connection from the datasource", ex);
        }
    }
View Full Code Here

                connection = DriverManager.getConnection(creationUrl.toString(), username, password);
                logWarnings(connection);
            }
            catch (Exception ex)
            {
                throw new DatabaseOperationException("Error while trying to create a database", ex);
            }
            finally
            {
                if (connection != null)
                {
View Full Code Here

        stmt.execute("SET textsize "+size);
      }
      catch (SQLException ex)
      {
        throw new DatabaseOperationException(ex);
      }
      finally
      {
        closeStatement(stmt);
        returnConnection(connection);
View Full Code Here

          stream.close();
          return result;
        }
        catch (IOException ex)
        {
          throw new DatabaseOperationException("Error while extracting the value of column " + columnName + " of type " +
                                           TypeMap.getJdbcTypeName(jdbcType) + " from a result set", ex);
        }
      }
    }
    else
View Full Code Here

                connection = DriverManager.getConnection(connectionUrl, username, password);
                logWarnings(connection);
            }
            catch (Exception ex)
            {
                throw new DatabaseOperationException("Error while trying to create a database", ex);
            }
            finally
            {
                if (connection != null)
                {
View Full Code Here

                connection = DriverManager.getConnection(creationUrl.toString(), username, password);
                logWarnings(connection);
            }
            catch (Exception ex)
            {
                throw new DatabaseOperationException("Error while trying to create a database", ex);
            }
            finally
            {
                if (connection != null)
                {
View Full Code Here

                initFromMetaData(model);
            }
            catch (SQLException ex)
            {
                cleanUp();
                throw new DatabaseOperationException("Could not read the metadata of the result set", ex);
            }
        }
        else
        {
            _isAtEnd = true;
View Full Code Here

                return bean;
            }
            catch (Exception ex)
            {
                cleanUp();
                throw new DatabaseOperationException("Exception while reading the row from the resultset", ex);
            }
        }
    }
View Full Code Here

                _needsAdvancing = false;
            }
            catch (SQLException ex)
            {
                cleanUp();
                throw new DatabaseOperationException("Could not retrieve next row from result set", ex);
            }
            if (_isAtEnd)
            {
                cleanUp();
            }
View Full Code Here

TOP

Related Classes of org.apache.ddlutils.DatabaseOperationException

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.