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


Java DbException.convert方法代码示例

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


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

示例1: removeRow

import org.h2.message.DbException; //导入方法依赖的package包/类
@Override
public void removeRow(Session session, Row row) {
    lastModificationId = database.getNextModificationDataId();
    Transaction t = getTransaction(session);
    long savepoint = t.setSavepoint();
    try {
        for (int i = indexes.size() - 1; i >= 0; i--) {
            Index index = indexes.get(i);
            index.remove(session, row);
        }
    } catch (Throwable e) {
        t.rollbackToSavepoint(savepoint);
        throw DbException.convert(e);
    }
    analyzeIfRequired(session);
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:17,代码来源:MVTable.java

示例2: ConnectionInfo

import org.h2.message.DbException; //导入方法依赖的package包/类
/**
 * Create a connection info object.
 *
 * @param u the database URL (must start with jdbc:h2:)
 * @param info the connection properties
 */
public ConnectionInfo(String u, Properties info) {
    u = remapURL(u);
    this.originalURL = u;
    if (!u.startsWith(Constants.START_URL)) {
        throw DbException.getInvalidValueException("url", u);
    }
    this.url = u;
    readProperties(info);
    readSettingsFromURL();
    setUserName(removeProperty("USER", ""));
    convertPasswords();
    name = url.substring(Constants.START_URL.length());
    parseName();
    String recoverTest = removeProperty("RECOVER_TEST", null);
    if (recoverTest != null) {
        FilePathRec.register();
        try {
            Utils.callStaticMethod("org.h2.store.RecoverTester.init", recoverTest);
        } catch (Exception e) {
            throw DbException.convert(e);
        }
        name = "rec:" + name;
    }
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:31,代码来源:ConnectionInfo.java

示例3: 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

示例4: removeAllForTable

import org.h2.message.DbException; //导入方法依赖的package包/类
@Override
public void removeAllForTable(int tableId) {
    init();
    try {
        String sql = "SELECT ID FROM " + LOBS + " WHERE TABLE = ?";
        PreparedStatement prep = prepare(sql);
        prep.setInt(1, tableId);
        ResultSet rs = prep.executeQuery();
        while (rs.next()) {
            removeLob(rs.getLong(1));
        }
        reuse(sql, prep);
    } catch (SQLException e) {
        throw DbException.convert(e);
    }
    if (tableId == LobStorageFrontend.TABLE_ID_SESSION_VARIABLE) {
        removeAllForTable(LobStorageFrontend.TABLE_TEMP);
        removeAllForTable(LobStorageFrontend.TABLE_RESULT);
    }
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:21,代码来源:LobStorageBackend.java

示例5: startServer

import org.h2.message.DbException; //导入方法依赖的package包/类
private void startServer(String key) {
    try {
        server = Server.createTcpServer(
                "-tcpPort", Integer.toString(autoServerPort),
                "-tcpAllowOthers",
                "-tcpDaemon",
                "-key", key, databaseName);
        server.start();
    } catch (SQLException e) {
        throw DbException.convert(e);
    }
    String localAddress = NetUtils.getLocalAddress();
    String address = localAddress + ":" + server.getPort();
    lock.setProperty("server", address);
    String hostName = NetUtils.getHostName(localAddress);
    lock.setProperty("hostName", hostName);
    lock.save();
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:19,代码来源:Database.java

示例6: exec

import org.h2.message.DbException; //导入方法依赖的package包/类
private static int exec(String... args) {
    ByteArrayOutputStream buff = new ByteArrayOutputStream();
    try {
        ProcessBuilder builder = new ProcessBuilder();
        // The javac executable allows some of it's flags
        // to be smuggled in via environment variables.
        // But if it sees those flags, it will write out a message
        // to stderr, which messes up our parsing of the output.
        builder.environment().remove("JAVA_TOOL_OPTIONS");
        builder.command(args);

        Process p = builder.start();
        copyInThread(p.getInputStream(), buff);
        copyInThread(p.getErrorStream(), buff);
        p.waitFor();
        String err = new String(buff.toByteArray(), Constants.UTF8);
        throwSyntaxError(err);
        return p.exitValue();
    } catch (Exception e) {
        throw DbException.convert(e);
    }
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:23,代码来源:SourceCompiler.java

示例7: read

import org.h2.message.DbException; //导入方法依赖的package包/类
/**
 * Construct a local result set by reading all data from a regular result
 * set.
 *
 * @param session the session
 * @param rs the result set
 * @param maxrows the maximum number of rows to read (0 for no limit)
 * @return the local result set
 */
public static LocalResult read(Session session, ResultSet rs, int maxrows) {
    Expression[] cols = Expression.getExpressionColumns(session, rs);
    int columnCount = cols.length;
    LocalResult result = new LocalResult(session, cols, columnCount);
    try {
        for (int i = 0; (maxrows == 0 || i < maxrows) && rs.next(); i++) {
            Value[] list = new Value[columnCount];
            for (int j = 0; j < columnCount; j++) {
                int type = result.getColumnType(j);
                list[j] = DataType.readValue(session, rs, j + 1, type);
            }
            result.addRow(list);
        }
    } catch (SQLException e) {
        throw DbException.convert(e);
    }
    result.done();
    return result;
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:29,代码来源:LocalResult.java

示例8: optimize

import org.h2.message.DbException; //导入方法依赖的package包/类
@Override
public Expression optimize(Session session) {
    userConnection = session.createConnection(false);
    int len = args.length;
    argTypes = new int[len];
    for (int i = 0; i < len; i++) {
        Expression expr = args[i];
        args[i] = expr.optimize(session);
        int type = expr.getType();
        argTypes[i] = type;
    }
    try {
        Aggregate aggregate = getInstance();
        dataType = aggregate.getInternalType(argTypes);
    } catch (SQLException e) {
        throw DbException.convert(e);
    }
    return this;
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:20,代码来源:JavaAggregate.java

示例9: open

import org.h2.message.DbException; //导入方法依赖的package包/类
private void open() {
    try {
        conn = JdbcUtils.getConnection(driver, url, user, password);
    } catch (SQLException e) {
        throw DbException.convert(e);
    }
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:8,代码来源:TableLinkConnection.java

示例10: javacCompile

import org.h2.message.DbException; //导入方法依赖的package包/类
/**
 * Compile the given class. This method tries to use the class
 * "com.sun.tools.javac.Main" if available. If not, it tries to run "javac"
 * in a separate process.
 *
 * @param packageName the package name
 * @param className the class name
 * @param source the source code
 * @return the class file
 */
byte[] javacCompile(String packageName, String className, String source) {
    File dir = new File(COMPILE_DIR);
    if (packageName != null) {
        dir = new File(dir, packageName.replace('.', '/'));
        FileUtils.createDirectories(dir.getAbsolutePath());
    }
    File javaFile = new File(dir, className + ".java");
    File classFile = new File(dir, className + ".class");
    try {
        OutputStream f = FileUtils.newOutputStream(javaFile.getAbsolutePath(), false);
        Writer out = IOUtils.getBufferedWriter(f);
        classFile.delete();
        out.write(source);
        out.close();
        if (JAVAC_SUN != null) {
            javacSun(javaFile);
        } else {
            javacProcess(javaFile);
        }
        byte[] data = new byte[(int) classFile.length()];
        DataInputStream in = new DataInputStream(new FileInputStream(classFile));
        in.readFully(data);
        in.close();
        return data;
    } catch (Exception e) {
        throw DbException.convert(e);
    } finally {
        javaFile.delete();
        classFile.delete();
    }
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:42,代码来源:SourceCompiler.java

示例11: get

import org.h2.message.DbException; //导入方法依赖的package包/类
/**
 * Get or create a geometry value for the given geometry.
 *
 * @param s the WKT representation of the geometry
 * @return the value
 */
public static ValueGeometry get(String s) {
    try {
        Geometry g = new WKTReader().read(s);
        return get(g);
    } catch (ParseException ex) {
        throw DbException.convert(ex);
    }
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:15,代码来源:ValueGeometry.java

示例12: getGeometryNoCopy

import org.h2.message.DbException; //导入方法依赖的package包/类
public Geometry getGeometryNoCopy() {
    if (geometry == null) {
        try {
            geometry = new WKBReader().read(bytes);
        } catch (ParseException ex) {
            throw DbException.convert(ex);
        }
    }
    return geometry;
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:11,代码来源:ValueGeometry.java

示例13: getCopy

import org.h2.message.DbException; //导入方法依赖的package包/类
/**
 * Create a result set value for the given result set. The result set will
 * be fully read in memory. The original result set is not closed.
 *
 * @param rs the result set
 * @param maxrows the maximum number of rows to read (0 to just read the
 *            meta data)
 * @return the value
 */
public static ValueResultSet getCopy(ResultSet rs, int maxrows) {
    try {
        ResultSetMetaData meta = rs.getMetaData();
        int columnCount = meta.getColumnCount();
        SimpleResultSet simple = new SimpleResultSet();
        simple.setAutoClose(false);
        ValueResultSet val = new ValueResultSet(simple);
        for (int i = 0; i < columnCount; i++) {
            String name = meta.getColumnLabel(i + 1);
            int sqlType = meta.getColumnType(i + 1);
            int precision = meta.getPrecision(i + 1);
            int scale = meta.getScale(i + 1);
            simple.addColumn(name, sqlType, precision, scale);
        }
        for (int i = 0; i < maxrows && rs.next(); i++) {
            Object[] list = new Object[columnCount];
            for (int j = 0; j < columnCount; j++) {
                list[j] = rs.getObject(j + 1);
            }
            simple.addRow(list);
        }
        return val;
    } catch (SQLException e) {
        throw DbException.convert(e);
    }
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:36,代码来源:ValueResultSet.java

示例14: FunctionCursorResultSet

import org.h2.message.DbException; //导入方法依赖的package包/类
FunctionCursorResultSet(Session session, ResultSet result) {
    this.session = session;
    this.result = result;
    try {
        this.meta = result.getMetaData();
    } catch (SQLException e) {
        throw DbException.convert(e);
    }
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:10,代码来源:FunctionCursorResultSet.java

示例15: updateAggregate

import org.h2.message.DbException; //导入方法依赖的package包/类
@Override
public void updateAggregate(Session session) {
    HashMap<Expression, Object> group = select.getCurrentGroup();
    if (group == null) {
        // this is a different level (the enclosing query)
        return;
    }

    int groupRowId = select.getCurrentGroupRowId();
    if (lastGroupRowId == groupRowId) {
        // already visited
        return;
    }
    lastGroupRowId = groupRowId;

    Aggregate agg = (Aggregate) group.get(this);
    try {
        if (agg == null) {
            agg = getInstance();
            group.put(this, agg);
        }
        Object[] argValues = new Object[args.length];
        Object arg = null;
        for (int i = 0, len = args.length; i < len; i++) {
            Value v = args[i].getValue(session);
            v = v.convertTo(argTypes[i]);
            arg = v.getObject();
            argValues[i] = arg;
        }
        if (args.length == 1) {
            agg.add(arg);
        } else {
            agg.add(argValues);
        }
    } catch (SQLException e) {
        throw DbException.convert(e);
    }
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:39,代码来源:JavaAggregate.java


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