当前位置: 首页>>代码示例>>Java>>正文


Java DbException类代码示例

本文整理汇总了Java中org.h2.message.DbException的典型用法代码示例。如果您正苦于以下问题:Java DbException类的具体用法?Java DbException怎么用?Java DbException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DbException类属于org.h2.message包,在下文中一共展示了DbException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: newDirectoryStream

import org.h2.message.DbException; //导入依赖的package包/类
@Override
public List<FilePath> newDirectoryStream() {
    ArrayList<FilePath> list = New.arrayList();
    File f = new File(name);
    try {
        String[] files = f.list();
        if (files != null) {
            String base = f.getCanonicalPath();
            if (!base.endsWith(SysProperties.FILE_SEPARATOR)) {
                base += SysProperties.FILE_SEPARATOR;
            }
            for (int i = 0, len = files.length; i < len; i++) {
                list.add(getPath(base + files[i]));
            }
        }
        return list;
    } catch (IOException e) {
        throw DbException.convertIOException(e, name);
    }
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:21,代码来源:FilePathDisk.java

示例2: getNotCompareType

import org.h2.message.DbException; //导入依赖的package包/类
private int getNotCompareType() {
    switch (compareType) {
    case EQUAL:
        return NOT_EQUAL;
    case EQUAL_NULL_SAFE:
        return NOT_EQUAL_NULL_SAFE;
    case NOT_EQUAL:
        return EQUAL;
    case NOT_EQUAL_NULL_SAFE:
        return EQUAL_NULL_SAFE;
    case BIGGER_EQUAL:
        return SMALLER;
    case BIGGER:
        return SMALLER_EQUAL;
    case SMALLER_EQUAL:
        return BIGGER;
    case SMALLER:
        return BIGGER_EQUAL;
    case IS_NULL:
        return IS_NOT_NULL;
    case IS_NOT_NULL:
        return IS_NULL;
    default:
        throw DbException.throwInternalError("type=" + compareType);
    }
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:27,代码来源:Comparison.java

示例3: removeOrphanedLobs

import org.h2.message.DbException; //导入依赖的package包/类
private void removeOrphanedLobs() {
    // remove all session variables and temporary lobs
    if (!persistent) {
        return;
    }
    boolean lobStorageIsUsed = infoSchema.findTableOrView(
            systemSession, LobStorageBackend.LOB_DATA_TABLE) != null;
    lobStorageIsUsed |= mvStore != null;
    if (!lobStorageIsUsed) {
        return;
    }
    try {
        getLobStorage();
        lobStorage.removeAllForTable(
                LobStorageFrontend.TABLE_ID_SESSION_VARIABLE);
    } catch (DbException e) {
        trace.error(e, "close");
    }
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:20,代码来源:Database.java

示例4: getInputStream

import org.h2.message.DbException; //导入依赖的package包/类
@Override
public InputStream getInputStream() {
    if (small != null) {
        return new ByteArrayInputStream(small);
    } else if (fileName != null) {
        FileStore store = handler.openFile(fileName, "r", true);
        boolean alwaysClose = SysProperties.lobCloseBetweenReads;
        return new BufferedInputStream(new FileStoreInputStream(store,
                handler, false, alwaysClose), Constants.IO_BUFFER_SIZE);
    }
    long byteCount = (type == Value.BLOB) ? precision : -1;
    try {
        return handler.getLobStorage().getInputStream(this, hmac, byteCount);
    } catch (IOException e) {
        throw DbException.convertIOException(e, toString());
    }
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:18,代码来源:ValueLobDb.java

示例5: grantRole

import org.h2.message.DbException; //导入依赖的package包/类
private void grantRole(Role grantedRole) {
    if (grantedRole != grantee && grantee.isRoleGranted(grantedRole)) {
        return;
    }
    if (grantee instanceof Role) {
        Role granteeRole = (Role) grantee;
        if (grantedRole.isRoleGranted(granteeRole)) {
            // cyclic role grants are not allowed
            throw DbException.get(ErrorCode.ROLE_ALREADY_GRANTED_1, grantedRole.getSQL());
        }
    }
    Database db = session.getDatabase();
    int id = getObjectId();
    Right right = new Right(db, id, grantee, grantedRole);
    db.addDatabaseObject(session, right);
    grantee.grantRole(grantedRole, right);
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:18,代码来源:GrantRevoke.java

示例6: openOutput

import org.h2.message.DbException; //导入依赖的package包/类
/**
 * Open the output stream.
 */
void openOutput() {
    String file = getFileName();
    if (file == null) {
        return;
    }
    if (isEncrypted()) {
        initStore();
        out = new FileStoreOutputStream(store, this, compressionAlgorithm);
        // always use a big buffer, otherwise end-of-block is written a lot
        out = new BufferedOutputStream(out, Constants.IO_BUFFER_SIZE_COMPRESS);
    } else {
        OutputStream o;
        try {
            o = FileUtils.newOutputStream(file, false);
        } catch (IOException e) {
            throw DbException.convertIOException(e, null);
        }
        out = new BufferedOutputStream(o, Constants.IO_BUFFER_SIZE);
        out = CompressTool.wrapOutputStream(out, compressionAlgorithm, SCRIPT_SQL);
    }
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:25,代码来源:ScriptBase.java

示例7: read

import org.h2.message.DbException; //导入依赖的package包/类
@Override
public int read(byte[] buff, int off, int length) throws IOException {
    if (length == 0) {
        return 0;
    }
    length = (int) Math.min(length, remainingBytes);
    if (length == 0) {
        return -1;
    }
    try {
        length = handler.readLob(lob, hmac, pos, buff, off, length);
    } catch (DbException e) {
        throw DbException.convertToIOException(e);
    }
    remainingBytes -= length;
    if (length == 0) {
        return -1;
    }
    pos += length;
    return length;
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:22,代码来源:LobStorageRemoteInputStream.java

示例8: rebuildIndexBuffered

import org.h2.message.DbException; //导入依赖的package包/类
private void rebuildIndexBuffered(Session session, Index index) {
    Index scan = getScanIndex(session);
    long remaining = scan.getRowCount(session);
    long total = remaining;
    Cursor cursor = scan.find(session, null, null);
    long i = 0;
    int bufferSize = (int) Math.min(total, database.getMaxMemoryRows());
    ArrayList<Row> buffer = New.arrayList(bufferSize);
    String n = getName() + ":" + index.getName();
    int t = MathUtils.convertLongToInt(total);
    while (cursor.next()) {
        Row row = cursor.get();
        buffer.add(row);
        database.setProgress(DatabaseEventListener.STATE_CREATE_INDEX, n,
                MathUtils.convertLongToInt(i++), t);
        if (buffer.size() >= bufferSize) {
            addRowsToIndex(session, buffer, index);
        }
        remaining--;
    }
    addRowsToIndex(session, buffer, index);
    if (SysProperties.CHECK && remaining != 0) {
        DbException.throwInternalError("rowcount remaining=" + remaining +
                " " + getName());
    }
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:27,代码来源:MVTable.java

示例9: assertThrows

import org.h2.message.DbException; //导入依赖的package包/类
/**
 * Verify the next method call on the object will throw an exception.
 *
 * @param <T> the class of the object
 * @param expectedErrorCode the expected error code
 * @param obj the object to wrap
 * @return a proxy for the object
 */
protected <T> T assertThrows(final int expectedErrorCode, final T obj) {
    return assertThrows(new ResultVerifier() {
        @Override
        public boolean verify(Object returnValue, Throwable t, Method m,
                Object... args) {
            int errorCode;
            if (t instanceof DbException) {
                errorCode = ((DbException) t).getErrorCode();
            } else if (t instanceof SQLException) {
                errorCode = ((SQLException) t).getErrorCode();
            } else {
                errorCode = 0;
            }
            if (errorCode != expectedErrorCode) {
                AssertionError ae = new AssertionError(
                        "Expected an SQLException or DbException with error code "
                                + expectedErrorCode);
                ae.initCause(t);
                throw ae;
            }
            return false;
        }
    }, obj);
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:33,代码来源:TestBase.java

示例10: rename

import org.h2.message.DbException; //导入依赖的package包/类
/**
 * Rename an object.
 *
 * @param obj the object to rename
 * @param newName the new name
 */
public void rename(SchemaObject obj, String newName) {
    int type = obj.getType();
    HashMap<String, SchemaObject> map = getMap(type);
    if (SysProperties.CHECK) {
        if (!map.containsKey(obj.getName())) {
            DbException.throwInternalError("not found: " + obj.getName());
        }
        if (obj.getName().equals(newName) || map.containsKey(newName)) {
            DbException.throwInternalError("object already exists: " + newName);
        }
    }
    obj.checkRename();
    map.remove(obj.getName());
    freeUniqueName(obj.getName());
    obj.rename(newName);
    map.put(newName, obj);
    freeUniqueName(newName);
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:25,代码来源:Schema.java

示例11: remapURL

import org.h2.message.DbException; //导入依赖的package包/类
private static String remapURL(String url) {
    String urlMap = SysProperties.URL_MAP;
    if (urlMap != null && urlMap.length() > 0) {
        try {
            SortedProperties prop;
            prop = SortedProperties.loadProperties(urlMap);
            String url2 = prop.getProperty(url);
            if (url2 == null) {
                prop.put(url, "");
                prop.store(urlMap);
            } else {
                url2 = url2.trim();
                if (url2.length() > 0) {
                    return url2;
                }
            }
        } catch (IOException e) {
            throw DbException.convert(e);
        }
    }
    return url;
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:23,代码来源:ConnectionInfo.java

示例12: expand

import org.h2.message.DbException; //导入依赖的package包/类
@Override
public void expand(byte[] in, int inPos, int inLen, byte[] out, int outPos,
        int outLen) {
    Inflater decompresser = new Inflater();
    decompresser.setInput(in, inPos, inLen);
    decompresser.finished();
    try {
        int len = decompresser.inflate(out, outPos, outLen);
        if (len != outLen) {
            throw new DataFormatException(len + " " + outLen);
        }
    } catch (DataFormatException e) {
        throw DbException.get(ErrorCode.COMPRESSION_ERROR, e);
    }
    decompresser.end();
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:17,代码来源:CompressDeflate.java

示例13: getNext

import org.h2.message.DbException; //导入依赖的package包/类
/**
 * Get the next value for this sequence.
 *
 * @param session the session
 * @return the next value
 */
public synchronized long getNext(Session session) {
    boolean needsFlush = false;
    if ((increment > 0 && value >= valueWithMargin) ||
            (increment < 0 && value <= valueWithMargin)) {
        valueWithMargin += increment * cacheSize;
        needsFlush = true;
    }
    if ((increment > 0 && value > maxValue) ||
            (increment < 0 && value < minValue)) {
        if (cycle) {
            value = increment > 0 ? minValue : maxValue;
            valueWithMargin = value + (increment * cacheSize);
            needsFlush = true;
        } else {
            throw DbException.get(ErrorCode.SEQUENCE_EXHAUSTED, getName());
        }
    }
    if (needsFlush) {
        flush(session);
    }
    long v = value;
    value += increment;
    return v;
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:31,代码来源:Sequence.java

示例14: initJavaObjectSerializer

import org.h2.message.DbException; //导入依赖的package包/类
private void initJavaObjectSerializer() {
    if (javaObjectSerializerInitialized) {
        return;
    }
    synchronized (this) {
        if (javaObjectSerializerInitialized) {
            return;
        }
        String serializerName = javaObjectSerializerName;
        if (serializerName != null) {
            serializerName = serializerName.trim();
            if (!serializerName.isEmpty() &&
                    !serializerName.equals("null")) {
                try {
                    javaObjectSerializer = (JavaObjectSerializer)
                            JdbcUtils.loadUserClass(serializerName).newInstance();
                } catch (Exception e) {
                    throw DbException.convert(e);
                }
            }
        }
        javaObjectSerializerInitialized = true;
    }
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:25,代码来源:Database.java

示例15: update

import org.h2.message.DbException; //导入依赖的package包/类
@Override
public int update() {
    session.commit(true);
    Database db = session.getDatabase();
    session.getUser().checkRight(oldTable, Right.ALL);
    Table t = getSchema().findTableOrView(session, newTableName);
    if (t != null && hidden && newTableName.equals(oldTable.getName())) {
        if (!t.isHidden()) {
            t.setHidden(hidden);
            oldTable.setHidden(true);
            db.updateMeta(session, oldTable);
        }
        return 0;
    }
    if (t != null || newTableName.equals(oldTable.getName())) {
        throw DbException.get(ErrorCode.TABLE_OR_VIEW_ALREADY_EXISTS_1, newTableName);
    }
    if (oldTable.isTemporary()) {
        throw DbException.getUnsupportedException("temp table");
    }
    db.renameSchemaObject(session, oldTable, newTableName);
    return 0;
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:24,代码来源:AlterTableRename.java


注:本文中的org.h2.message.DbException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。