Package java.sql

Examples of java.sql.SQLException


                if (rollback) {
                    // item not found - correct behavior
                    db.rollback();
                    return;
                }
                throw new SQLException("item not found: " + olId + " "
                        + olSupplyId);
            }
            BigDecimal price = rs.getBigDecimal(1);
            // i_name
            rs.getString(2);
            String data = rs.getString(3);
            rs.close();
            prep = prepare("SELECT S_QUANTITY, S_DATA, "
                    + "S_DIST_01, S_DIST_02, S_DIST_03, S_DIST_04, S_DIST_05, "
                    + "S_DIST_06, S_DIST_07, S_DIST_08, S_DIST_09, S_DIST_10 "
                    + "FROM STOCK WHERE S_I_ID=? AND S_W_ID=?");
            prep.setInt(1, olId);
            prep.setInt(2, olSupplyId);
            rs = db.query(prep);
            if (!rs.next()) {
                if (rollback) {
                    // item not found - correct behavior
                    db.rollback();
                    return;
                }
                throw new SQLException("item not found: " + olId + " "
                        + olSupplyId);
            }
            int sQuantity = rs.getInt(1);
            String sData = rs.getString(2);
            String[] dist = new String[10];
View Full Code Here


        // test JQTable.primaryKey=id
        try {
            db.insertAll(ProductAnnotationOnly.getList());
        } catch (RuntimeException r) {
            SQLException s = (SQLException) r.getCause();
            assertEquals(ErrorCode.DUPLICATE_KEY_1, s.getErrorCode());
        }
    }
View Full Code Here

        // test JQColumn.primaryKey=true
        try {
            db.insertAll(ProductMixedAnnotation.getList());
        } catch (RuntimeException r) {
            SQLException s = (SQLException) r.getCause();
            assertEquals(ErrorCode.DUPLICATE_KEY_1, s.getErrorCode());
        }
    }
View Full Code Here

        try {
            Db noCreateDb = Db.open("jdbc:h2:mem:", "sa", "sa");
            noCreateDb.insertAll(ProductNoCreateTable.getList());
            noCreateDb.close();
        } catch (RuntimeException r) {
            SQLException s = (SQLException) r.getCause();
            assertEquals(ErrorCode.TABLE_OR_VIEW_NOT_FOUND_1, s.getErrorCode());
        }
    }
View Full Code Here

                    "where table_schema='PUBLIC'");
        }

        public void fire(Connection conn, Object[] oldRow, Object[] newRow) throws SQLException {
            if (oldRow != null || newRow != null) {
                throw new SQLException("old and new must be null");
            }
            conn.createStatement().execute("delete from meta_tables");
            prepMeta.execute();
        }
View Full Code Here

  @Test public void testNotification() throws Exception {
    XAConnectionImpl xaConn = new XAConnectionImpl(new XAConnectionImpl.ConnectionSource() {
      @Override
      public ConnectionImpl createConnection() throws SQLException {
        ConnectionImpl c = Mockito.mock(ConnectionImpl.class);
        Mockito.doThrow(new SQLException(new InvalidSessionException())).when(c).commit();
        return c;
      }
    });
    ConnectionEventListener cel = Mockito.mock(ConnectionEventListener.class);
    xaConn.addConnectionEventListener(cel);
View Full Code Here

     */
    private Element produceResults(ResultSet object, int beginRow, int endRow)
            throws JDOMException, SQLException {

      if (object.isClosed()) {
            throw new SQLException(
            "ResultSet is closed at this point, unable to product results"); //$NON-NLS-1$
       
      }
     
        if ( beginRow < START_ROW ) {
View Full Code Here

            try {
              result = ObjectConverterUtil.convertToString(c.getAsciiStream());
         
        } catch (Throwable e) {
          // TODO Auto-generated catch block
          throw new SQLException(e);
        }
          } else if (object instanceof Blob){
                Blob b = (Blob)object;
                try {
                  result = ObjectConverterUtil.convertToString(b.getBinaryStream());
           
          } catch (Throwable e) {
            // TODO Auto-generated catch block
            throw new SQLException(e);
          }
            } else if (object instanceof SQLXML){
              SQLXML s = (SQLXML)object;
            try {
              result = ObjectConverterUtil.convertToString(s.getBinaryStream());
         
        } catch (Throwable e) {
          // TODO Auto-generated catch block
          throw new SQLException(e);
        }
            }
        } else {
          result = object.toString();
        }
View Full Code Here

    }

    protected void validateProperties( final String userName, final String password) throws java.sql.SQLException {
        String reason = reasonWhyInvalidApplicationName(this.applicationName);
        if ( reason != null ) {
            throw new SQLException(reason);
        }

        reason = reasonWhyInvalidDatabaseName(this.databaseName);
        if ( reason != null ) {
            throw new SQLException(reason);
        }

        reason = reasonWhyInvalidDatabaseVersion(this.databaseVersion);
        if ( reason != null ) {
            throw new SQLException(reason);
        }

        reason = reasonWhyInvalidDataSourceName(this.dataSourceName);
        if ( reason != null ) {
            throw new SQLException(reason);
        }

        reason = reasonWhyInvalidDescription(this.description);
        if ( reason != null ) {
            throw new SQLException(reason);
        }

        final String pwd = password != null ? password : getPassword();
        reason = reasonWhyInvalidPassword(pwd);
        if ( reason != null ) {
            throw new SQLException(reason);
        }

        reason = reasonWhyInvalidPartialResultsMode(this.partialResultsMode);
        if (reason != null) {
            throw new SQLException(reason);
        }

        reason = reasonWhyInvalidFetchSize(this.fetchSize);
        if (reason != null) {
            throw new SQLException(reason);
        }

        final String user = userName != null ? userName : getUser();
        reason = reasonWhyInvalidUser(user);
        if ( reason != null ) {
            throw new SQLException(reason);
        }

        reason = reasonWhyInvalidTransactionAutoWrap(this.transactionAutoWrap);
        if ( reason != null ) {
            throw new SQLException(reason);
        }
       
        if (this.queryTimeout < 0) {
          throw new TeiidSQLException(JDBCPlugin.Util.getString("MMStatement.Bad_timeout_value")); //$NON-NLS-1$
        }
View Full Code Here

                        throw DbException.convert(e);
                    }
                }
            } catch (DbException e) {
                e = e.addSQL(sql);
                SQLException s = e.getSQLException();
                database.exceptionThrown(s, sql);
                database.checkPowerOff();
                if (s.getErrorCode() == ErrorCode.DEADLOCK_1) {
                    session.rollback();
                } else if (s.getErrorCode() == ErrorCode.OUT_OF_MEMORY) {
                    // there is a serious problem:
                    // the transaction may be applied partially
                    // in this case we need to panic:
                    // close the database
                    callStop = false;
View Full Code Here

TOP

Related Classes of java.sql.SQLException

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.