JDBC Transport Examples

关于jdbc批量操作(addBatch, executeBatch)的测试 由于项目上有大批量数据插入和更新的操作,所以使用了jdbc的批量操作功能。在此之前参考了很多文章包括jdbc的手册(https://www.tutorialspoint.com/jdbc/jdbc-batch-processing.htm),有说需要使用事务的,也有的文章没有使用事务,试了很久,发现代码一直没有按照期望的执行,还是逐条操作数据库。后来在偶然间看到了文章提到需要设置rewriteBa 阅读详情

This page describes the examples you can run for the Mule Enterprise JDBC transport. These examples are designed to work with Oracle databases only.

Setup

The Mule Enterprise JDBC Examples are located in your installation at $MULE_HOME/examples/jdbc.

1. Before running any examples, do the following:

  • Run the statements in scripts/tables.ddl to create tables in your favorite database.
  • Edit the conf/db.properties file with your database connection configuration.
  • Copy your database driver to your $MULE_HOME/lib/user directory.

2. Run the examples using the "jdbc.bat" or "jdbc" shell script provided in this directory. After running the script, you will see the following:

$ ./jdbc.bat
Examples require that you set up your database first. See README for more details.
After your database is set up, choose one of the following examples to run:
1. Mules are born.  Read in 50 baby mules from a CSV File and create records in mule_source table.
2. View Mules.  Generate an XML report of Mules.  (http://localhost:8080/first20)
3. Clone Mules.  Clone mules using a Stored Procedure. (http://localhost:8080/clone)
4. Retire Mules.  Send mules to a retirement ranch (a.k.a the mule_target table).
5. Cleanup Mules.  Reset tables to run examples again (http://localhost:8080/cleanup).
Select the one you wish to execute and press Enter...

3. Choose the number of the Example you want to run.

The examples are designed to be run in order.

Example 1 - Mules Are Born

This example loads records from a CSV file to the database. The CSV file ("data/mules.csv") contains information about 50 baby mules born at various local ranches. The goal is to upload these records into a database table called "mule_source".

Configuration

See conf/jdbc-csv.xml

Features Used

This example uses the CSV Transformer to convert the CSV file into JDBC-format Maps and inserts these records into the database using a batch INSERT.

Running the Example

To run the example, choose option "1" after starting the Mule server. When the server starts, Mule will immediately load all the records.

To verify that the example loaded correctly, use your favorite database tool to see that there were 50 records inserted into the mule_source table.

SQL> select count(1) from mule_source;

COUNT(1)
----------
50

If you want to run the example again, first delete the records from mule_source.

Example 2 - See the Baby Mules

This example displays the mule records loaded into the database in Example 1.

Configuration

See conf/jdbc-xml-report.xml

Features Used

This example uses an outbound SELECT query to synchronously query the database. The results are transformed into XML using the XML transformer.

Running the Example

Start the Mule server and choose Example 2. Then, enter the URL http://localhost:8080/first20 into your web browser. You should see the first 20 mule records presented in XML format.

Example 3 - Mule Cloning

The following example assumes that you are using an Oracle database. However, you can adapt the stored procedure for other database platforms.

This example shows how to invoke a stored procedure in Mule. This particular stored procedure clones the records in the mule_source database (doubling the size of the table each time it is run). The goal is to create a large dataset that we can use in Example 4.

Configuration

See conf/jdbc-stored-procedure.xml

Features Used

This page uses an outbound SELECT query and stored procedure support to synchronously call a stored procedure.

Running the Example

Before running this example, run the statements in the scripts/oracle_procs.ddl to create the stored procedure and sequence.

Start the Mule server and choose Example 3. Then, enter the URL http://localhost:8080/clone into your web browser. You should see the current count of the number of mules in mule_source. Each time you refresh the page, the number of mules should double. Try refreshing several times until there are thousands or even millions of mules or more in the table. The mules multiply quickly!

Example 4 - Mass Mule Retirement

This example retires all our mules by transferring them from one database table (mule_source) to another (mule_target). We can think of this as a simple ETL use case.

Configuration

See conf/jdbc-etl.xml

Features Used

This page uses large dataset retrieval, an outbound SELECT query, and batch INSERT statements to transfer arbitrarily large numbers of records from one table another.

Running the Example

Before running this example, you can optionally change the location of the ID store in jdbc-etl.xml:

    <spring:bean id="idStore" class="org.mule.transport.jdbc.util.IdStore">
        <spring:property name="fileName" value="/tmp/eg-batches.txt"/>
    </spring:bean>

The default location is /tmp/eg-batches.txt on Linux/Unix and c:/tmp/eg-batches.txt on Windows.

Next, for better visibility into batch activity, add the following line to your log4j.properties file (in $MULE_HOME/conf):

log4j.logger.org.mule.providers.jdbc.components=DEBUG

Finally, start the server and choose Example 4. You should see the batches of records being processed in the logs:

DEBUG 2008-04-10 20:20:03,625 \[next_batch.2\] org.mule.transport.jdbc.components.BatchManager: Processing next batch
DEBUG 2008-04-10 20:20:03,625 \[next_batch.2\] org.mule.transport.jdbc.components.BatchManager: Next range: {lowerId=1, upperId=3000}
DEBUG 2008-04-10 20:20:04,531 \[next_batch.2\] org.mule.transport.jdbc.components.BatchManager: Processing next batch
DEBUG 2008-04-10 20:20:04,531 \[next_batch.2\] org.mule.transport.jdbc.components.BatchManager: Next range: {lowerId=3001, upperId=6000}
DEBUG 2008-04-10 20:20:05,531 \[next_batch.2\] org.mule.transport.jdbc.components.BatchManager: Processing next batch
DEBUG 2008-04-10 20:20:05,531 \[next_batch.2\] org.mule.transport.jdbc.components.BatchManager: Next range: {lowerId=6001, upperId=9000}

In this example, batches are configured to occur every 1 second, with a batch size of 3000.

Note that if you stop and restart the Mule server, the batches should resume processing where they left off.

Re-running the Examples

If you want to run these examples again, just delete all records from both mule_source and mule_target tables, and remove the file "/tmp/eg-batches.txt". In Oracle, this may be most efficiently done by using truncate, e.g. truncate table mule_source.

Alternatively, if on Oracle, start the server choose "Example 5" to cleanup the tables mule_source and mule_target. You still need to manually remove the file "/tmp/eg-batches.txt".

IDEA集成Tomcat全攻略:从开发调试到生产部署实战 Servlet容器是Java Web应用运行的核心环境,负责处理HTTP请求、管理Servlet生命周期并生成响应。Tomcat作为最主流的开源Servlet容器实现,其轻量、高效和规范兼容的特性,使其成为企业级应用部署的基石。通过将Tomcat与IntelliJ IDEA这一智能IDE深度集成,开发者可以在编码、调试和部署环节获得无缝体验,极大提升开发效率与问题排查能力。这种组合尤其适用于需要精确控制部署环境、调试传统Servlet/JSP项目或解决复杂生产问题的场景。例如,在应对“tomcat fail 阅读详情

相关推荐

docker一键部署笔记

默认 登录用户名: postgres如果遇到 FATAL: password authentication failed for user "XXX"有可能防火墙的问题,禁止外部访问解决方法: 在 data 的 pg_hba.conf 中的 ipv4 添加以下一行。

Angindem博客 475

批量处理(Batch processing

用Hibernate将 100 000 条记录插入到数据库的一个很自然的做法可能是这样的Session session = sessionFactory.openSession();Transaction tx = session.beginTransaction();for ( int i=0; i<100000; i++ ) { Customer customer = n

待定的专栏 1388

战国BC472年世界历史地图矢量文件SHP格式.zip

本资源为《战国BC472年世界历史地图矢量文件SHP格式》压缩包,文件大小约 2.26 MB,便于集中下载、整理和使用。具体内容请结合压缩包内的实际文件与说明查看。 在当前可读取的目录中,可见属性表(.dbf)、投影说明文件(.prj)、Shapefile 主文件(.shp)、Shapefile 索引(.shx)。建议解压后保持原有目录结构,先浏览文件清单与说明,再选择需要的资料进行加载或整理。 应用方面,可根据实际资料用于学习练习、资料检索、研究整理或项目参考。使用时可先确定所需内容,建立清晰的文件分类,再按项目要求进行筛选、转换与汇总。 使用 Shapefile 数据时,请把实际配套的 .shp、.shx、.dbf 等文件保存在同一目录,并保持同名关联;加载后再检查坐标系与中文字段显示。如需叠加其它数据,请先统一坐标与字段口径。 数据来源、时间范围、坐标系、字段定义、精度和使用条件,请以实际文件及原始说明为准。本介绍不对文件名之外尚未核实的信息作额外承诺。

149. JDBC 批处理

JDBC批处理技术通过将多条SQL语句打包成批次一次性执行,显著提升数据库操作效率。核心方法是addBatch()、executeBatch()和clearBatch(),适用于大数据量插入/更新、日志处理等场景。相比普通逐条执行,批处理减少网络I/O和资源消耗,性能提升明显。 使用PreparedStatement批处理时需注意:合理设置批处理大小(通常500-1000条),配合事务管理确保数据一致性,不同数据库驱动可能有特殊要求。

weixin_43484713的博客 886

Spacedesk保姆级教程:用旧平板给Windows电脑当副屏,从安装到避坑一步到位

本文提供Spacedesk保姆级教程,教你如何将旧平板变成Windows电脑的副屏,从软件安装到网络配置、显示优化及声音交互,一步步避开常见陷阱。通过WiFi实现扩展屏功能,支持4K分辨率和60Hz刷新率,让闲置设备焕发新生。

weixin_42524945的博客 1万+

华为产品安全基线

一、敏感信息安全传输 1、采用HTTPS安全协议传输 2、客户端本地保存的敏感信息,需要先加密再保存使用,不可逆支持PBKDF2(迭代10000次)加密保存,可逆支持AES256+IV保存,密钥支持可更新 二、认证鉴权 1、License中心与分析节点分布式部署,需要做用户名+口令安全认证,支持使用HTTPS安全协议。 2、客户端登录支持防暴力破解,支持验证码,多次连续尝试登陆失败后锁定账...

zileixu的博客 1万+

使用JDBC实现批量插入数据的最佳实践

通过使用JDBC的批处理操作,结合MySQL的批处理优化功能,可以显著提高批量插入数据的性能。在实际开发中,推荐在处理大批量数据时使用addBatch()等方法,并确保关闭自动提交模式以优化数据库操作的效率。

qq_42798343的博客 1557

Neo4j桌面版导入CVS文件

我们的relation.csv是这样的。

m0_53573725的博客 824

【JDBC系列】- jdbc的概念以及与数据库的交互流程

这次就来学习一下jdbc。本次所学习的大致内容是jdbc的概念与理解,以及如何去使用jdbc来实现Java程序和数据库进行打交道。

qq_43843951的博客 840

RoboDK 自定义机器人

本文介绍了如何在RoboDK中自定义机器人模型的方法。主要内容包括:1)通过CAD软件处理3D模型后导入RoboDK,使用分割工具简化模型结构;2)配置机器人的DH参数和关节运动范围;3)验证机器人运动效果后导出.robot文件。该方法可使自制机器人获得与ABB等商用机器人相同的仿真和控制功能。文章详细说明了模型处理、参数设置和验证的完整流程,为机器人开发者提供了实用的技术指导。

zhbi98 的技术 Blogs 2671

SAP物料分类账实战:从配置到月结的关键步骤(基于S/4HANA1909)

本文详细解析了在SAP S/4HANA 1909系统中,物料分类账从基础配置到月结操作的全流程。作为成本核算的核心,物料分类账通过多级价格确定实现实际成本核算,关键步骤包括激活物料分类账、配置自动过账科目(OBYC)、运行CKMLCP进行差异分摊与结算。文章旨在帮助财务与成本会计人员确保成本差异的准确归集与分摊,顺利完成月结。

weixin_28314575的博客 203

Hive 3.1.3 从零部署与调优实战:构建稳定离线数仓核心

数据仓库是处理海量离线数据的核心系统,其核心原理是将存储在分布式文件系统上的数据通过元数据管理映射为结构化表,并提供类SQL接口进行查询分析。Hive作为Hadoop生态中最经典的数据仓库工具,通过将HiveQL转换为MapReduce、Tez等计算任务,实现了在YARN资源调度框架上的大规模并行处理,技术价值在于以较低的成本为海量数据提供了稳定、可扩展的批处理能力,广泛应用于企业级数据仓库、ETL流程和离线报表分析等场景。本文聚焦于Hive 3.1.3版本的完整部署流程,深入解析其与Hadoop HDFS

weixin_30600197的博客 325

UQLab——其他概率分布随机变量转换标准Gaussian分布

1、使用UQLab将其他类型的随机变量转换成标准Gaussian分布; 2、使用科学计数法输出样本,方便后续ANSYS的调用分析; 3、基于MC的可靠度分析。 原随机变量分布类型: % 调用UQLab进行采样 clc clear uqlab %% Specify these distributions as a UQLab INPUT object: PriorOpts.Marginals(1...

ikhui7的博客 3016

MuleSoft+LangChain双引擎架构:企业AI编排实战指南

AI编排(AI Orchestration)是连接大模型与企业核心系统的关键技术范式,其本质在于解决确定性系统与概率性模型之间的范式冲突。通过协议转换、语义推理与结构化数据治理,实现安全、可审计、可回滚的AI能力落地。MuleSoft承担企业能力抽象与可信数据路由,LangChain负责动态Prompt组装、多步推理链与工具调用等AI原生逻辑,二者协同构成‘物理层+逻辑层’双引擎架构。该模式已广泛应用于销售智能助手、贷后预警、售后知识库等高合规要求场景,成为ERP/CRM与LLM之间不可或缺的‘翻译官’和‘

weixin_34151004的博客 644

win10下面安装MTK USB VCOM 驱动

win10下面安装MTK USB VCOM 驱动1.概述2.驱动准备3.主要步骤3.1禁用win10对没有签名驱动限制3.2通过设备管理器安装mtk usb vcom驱动3.3工具版本问题4.禁用win10对没有签名的驱动限制4.1在设置中打开 更新和安全4.2进入恢复4.3在高级启动中点击立即重新启动4.4电脑重启后的几个动作5.通过设备管理器安装MTK USB VCOM 驱动5.1准备驱动5....

qimi123456的专栏 3万+

基于YOLOv10深度学习的花生种子霉变检测系统

YOLO(You Only Look Once)是当前最先进的目标检测算法之一,具有快速、精准的特性。YOLOv10是YOLO系列的最新版本,相较于之前的版本,YOLOv10在特征提取、模型精度和速度上都有了显著的提升。YOLOv10采用了更深的卷积神经网络、更多的跨层特征融合方法,使得其在不同尺寸物体的检测和复杂场景的处理上都表现出了优异的性能。YOLOv10特别适合应用在需要快速处理并检测大量图像的任务中,如花生种子霉变检测等,能够实现精准、高效的检测。

2201_76125393的博客 650

工作中使用到的单词(软件开发)

1.エイリアス   alias 别名 powershell使用 get-help 命令时,会得到与此命令 相关(别名)的命令 2.プロキシ proxy 代 理 3.プロモート   promote 促进,提升   开发的系统新功能上线发布,有时会使用到这个词,比如 STプロモート 还有使用リリース这个词的。比如STリリース。个人认为两者含义相同。 4.見逃し み................................................................

sun0322 6万+

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

Java JDBC批处理 批量提交

在实际业务场景中,我们需要批量修改的时候恰好还有where条件,导致我们只能一条一条提交,没提交一次,又要获取一次jdbc连接,如果是十几条还好,但是上百条,就导致了响应速度慢。那么批处理就是解决这个问题,获取一次连接,然后把多条sql拼接成一条去执行。封装成了一个工具类,dataSource需要在调用方法的时候提前获取一下项目的jdbc连接。...

LiuJie 的微博 4459

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

Spring Boot入门系列之:六、Spring Boot整合spring-batch

spring-boot-batch 开发环境 开发工具:Intellij IDEA 2018.2.6 springboot: 2.0.6.RELEASE jdk:1.8.0_192 maven: 3.6.0 spring-boot-batch 轻量级,全面的批处理框架,旨在开发对企业系统日常运营至关重要的强大批处理应用程序。Spring Batch提供了可重复使用的功能,这些功能对于处理大量记录至...

leone的博客 7255

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

Batch Processing

为什么80%的码农都做不了架构师?>>> ...

weixin_34211761的博客 201

jdbc 批量操作 batch

PreparedStatement的预编译空间有限,数据量特别的大,所以 大量的数据处理的时候就需要使用Statement了 package com.testJDBC; import java.sql.Date; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.Result...

wangrong111222的博客 275

聊聊jdbc的batch操作

序 本文主要研究一下jdbc的batch的使用以及jpa的batch设置 batch statement的batch操作,可以批量进行insert或update操作,提升操作性能,特别是在大数据量的insert或update的时候。 使用方式 @Test public void testSqlInjectSafeBatch...

weixin_34132768的博客 476

Camunda 使用Oracle数据库 工作流部署时出现Entity was update by another transaction concurrently错误

官网论坛给的解决办法 大概是版本问题,在spring集成Camunda使用Oracle 数据库 是配置文件中要设置一下数据库选项 <property name="jdbcBatchProcessing" value="false"/> ...

henry的专栏 4997

JDBC batch批处理Statement executeBatch 详解

JDBC提供了数据库batch处理的能力,在数据大批量操作(新增、删除等)的情况下可以大幅度提升系统的性能。我以前接触的一个项目,在没有采用batch处理时,删除5万条数据大概要半个小时左右,后来对系统进行改造,采用了batch处理的方式,删除5万条数据基本上不会超过1分钟。看一

Base 8万+

标准JDBC步骤以及jdbc batch 批处理

jdbc batch 博客分类:   java jdbcbatch  jdbc包含batch功能,使用executeBatch方法实现批量操作。   void jdbc() throws Exception{ Connection conn = null; PreparedStatement statement = null; try { C

dreamoftch的专栏 1329

设置ODBC的自定义类CSetODBC

何志丹一,功能描述用于配置数据源用户名及密码.1,可以得到连接串,此串可用于CMyRecordset(派生于CRecordset)的GetDefaultConnect(),也可以用干CDataBase类OpenEx.2,如果用户配置正确,只需要配置一次,相关信息记录在文件.3,可以指定存储信息的文件名.因为有可能几个程序共用一个数据源.4,用户可以重新配置数据5,可以得到当前数据的类型.6

闻缺陷则喜何志丹 3211
上一篇: JDBC Transport
下一篇: Mule-Esb学习笔记一
borhunter
博客等级 码龄20年 4粉丝 3原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值