Package java.sql

Examples of java.sql.Statement.addBatch()


      countRepositoryLastUsageUpdates = resultSet.getInt(1);

      Statement updateStmt = con.createStatement();
      updateStmt.addBatch(lastLoginQuery);
      updateStmt.addBatch(lastUsageQuery);
      updateStmt.addBatch(repositoryLastUsageQuery);
      updateStmt.executeBatch();
    } catch (ClassNotFoundException e) {
      log.warn("Could not load jdbc driver for database configured in olat_config.xml. Driver: "+ driverClass, e);
      throw new StartupException("Could not load jdbc driver for database configured in olat_config.xml. Driver: "+ driverClass, e);
    } catch (SQLException e) {
View Full Code Here


     
      try {
        Class.forName(driverClass);
        con = DriverManager.getConnection(dbUrl, username, password);
        deleteStmt = con.createStatement();
        deleteStmt.addBatch(query_sub);
        deleteStmt.addBatch(query_pub);
        deleteStmt.executeBatch();
      } catch (ClassNotFoundException e){
        log.warn("Could not load jdbc driver for database configured in olat_config.xml. Driver: "+ driverClass, e);
        throw new StartupException("Could not load jdbc driver for database configured in olat_config.xml. Driver: "+ driverClass, e);
View Full Code Here

      try {
        Class.forName(driverClass);
        con = DriverManager.getConnection(dbUrl, username, password);
        deleteStmt = con.createStatement();
        deleteStmt.addBatch(query_sub);
        deleteStmt.addBatch(query_pub);
        deleteStmt.executeBatch();
      } catch (ClassNotFoundException e){
        log.warn("Could not load jdbc driver for database configured in olat_config.xml. Driver: "+ driverClass, e);
        throw new StartupException("Could not load jdbc driver for database configured in olat_config.xml. Driver: "+ driverClass, e);
      catch (SQLException e) {
View Full Code Here

            {
                for (String part : parts)
                {
                    final String sql= rewriter.rewrite(part, empty, context).getSql();
                    logger.add(sql);
                    stmt.addBatch(sql);
                }
            }
            catch (SQLException e)
            {
                throw new UnableToExecuteStatementException("Unable to configure JDBC statement", e);
View Full Code Here

  public void testExecuteBatch() throws SQLException {
    P6LogOptions.getActiveInstance().setExcludecategories("");
    // test batch inserts
    Statement stmt = connection.createStatement();
    String sql = "insert into customers(name,id) values ('jim', 101)";
    stmt.addBatch(sql);
    assertTrue(super.getLastLogEntry().contains(sql));
    assertTrue(super.getLastLogEntry().contains("|batch|"));
    sql = "insert into customers(name,id) values ('billy', 102)";
    stmt.addBatch(sql);
    assertTrue(super.getLastLogEntry().contains(sql));
View Full Code Here

    String sql = "insert into customers(name,id) values ('jim', 101)";
    stmt.addBatch(sql);
    assertTrue(super.getLastLogEntry().contains(sql));
    assertTrue(super.getLastLogEntry().contains("|batch|"));
    sql = "insert into customers(name,id) values ('billy', 102)";
    stmt.addBatch(sql);
    assertTrue(super.getLastLogEntry().contains(sql));
    assertTrue(super.getLastLogEntry().contains("|batch|"));

    stmt.executeBatch();
    assertTrue(super.getLastLogEntry().contains(sql));
View Full Code Here

                    continue;

                String value = pragmaTable.getProperty(key);
                if (value != null) {
                    String sql = String.format("pragma %s=%s", key, value);
                    stat.addBatch(sql);
                    count++;
                }
            }
            if (count > 0)
                stat.executeBatch();
View Full Code Here

    }
    Statement statement = conn.createStatement();
    for (int i = 0; i < removed.size(); i++) {
      String sql = String.format(SQL_DROP_COLUMN, removed.get(i));
      log.info(sql);
      statement.addBatch(sql);
    }
    for (int i = 0; i < added.size(); i++) {
      ColumnInfo info = findColumnInfo(columns, added.get(i));
      if (info != null) {
        String sql = String.format(SQL_ADD_COLUMN, info.getName(), info.getLength(),
View Full Code Here

      ColumnInfo info = findColumnInfo(columns, added.get(i));
      if (info != null) {
        String sql = String.format(SQL_ADD_COLUMN, info.getName(), info.getLength(),
            info.getDefaultValue());
        log.info(sql);
        statement.addBatch(sql);
      }
    }
    statement.executeBatch();
  }
View Full Code Here

    System.out.println("doing: " + createtable);
    stmt.execute(createtable);

    String inserttable = "insert into tab1 values(2, 'STRING_2')";
    System.out.println("doing: " + inserttable);
    stmt.addBatch(inserttable);
    inserttable = "insert into tab1 values(3, 'STRING_3')";
    System.out.println("doing: " + inserttable);
    stmt.addBatch(inserttable);
    inserttable = "insert into tab1 values(5, 'STRING_5')";
    System.out.println("doing: " + inserttable);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.