zoukankan      html  css  js  c++  java
  • Hibernate

    1、获取数据库连接

    Connection conn=SessionFactoryUtils.getDataSource(getSessionFactory()).getConnection(); 

    2、获取sequence下一个值

    Session session = null;

    session = this.getSession();
       // 查询下一个sequenceName的值
       sqlBuffer.append("select ").append(sequenceName).append(".nextval as nextval from dual");
       List list = session.createSQLQuery(sqlBuffer.toString()).list();
       if (list.size() == 1) {
        return list.get(0) + "";
       } else {
        // 手动抛出异常
        StringBuffer ex = new StringBuffer();
        ex.append("获取名字为:");
        ex.append(sequenceName);
        ex.append("码异常.");
        ex.append("SQL=");
        ex.append(sqlBuffer.toString());
        throw new Exception(ex.toString());
       }

  • 相关阅读:
    Spark基础
    flink杂记
    算法
    算法小结
    Java内存模型
    LeetCode---Backtracking && DP
    LeetCode---Sort && Segment Tree && Greedy
    LeetCode---Depth-first && Breadth-first
    LeetCode---Bit Manipulation && Design
    MD5
  • 原文地址:https://www.cnblogs.com/Defry/p/4548346.html
Copyright © 2011-2022 走看看