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".

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

相关推荐

IDEA集成Tomcat全攻略:从开发调试到生产部署实战

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

weixin_34279579的博客 327

批量处理(Batch processing

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

待定的专栏 1386

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

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

weixin_34151004的博客 643

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

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

qq_43843951的博客 839

docker一键部署笔记

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

Angindem博客 462

国央企创新负责人如何通过平台实现科研成果的快速识别与转化?.docx

科易网基于AI模型+行业大数据,在技术转移、成果转化、技术经纪、知识产权、产业创新、科技招商等垂直领域的多样化应用场景,推出科技创新领域的AI+工具与数智化解决方案,推动科技创新与产业创新智能化发展。

149. JDBC 批处理

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

weixin_43484713的博客 883

从网格划分到端口接地:一份给ADS新手的Momentum RF仿真避坑实操指南

本文为ADS新手提供Momentum RF仿真的实用指南,涵盖网格划分、端口接地、特殊结构处理等关键设置技巧。通过30-50 cells/λ原则、1/10波长限制等黄金法则,帮助用户平衡仿真精度与效率,避免常见错误,提升电磁仿真结果的准确性。

weixin_33692284的博客 506

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

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

qq_42798343的博客 1557

Paraview:Python Calculator Filter

python calculator过滤器 from paraview.simple import * connection = servermanager.Connect('localhost',11111) er = servermanager.sources.EnSightreader(CaseFileName='/.../data.case') er.PointArrays = ['x_velocity','1','y_velocity','1','z_velocity','1','cp','1']

haimianjie2012的专栏 3495

C++碰撞检测库FCL安装(MinGW,CMake)

FCL碰撞检测库、libccd\Eigen库编译配置,全流程问题记录

weixin_45650767的博客 4675

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

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

sun0322 6万+

从FinFET到NanoSheet:一文看懂TSMC制程技术的架构革命与性能飞跃

本文深入解析了TSMC从FinFET到NanoSheet的制程技术架构革命。FinFET通过三维立体结构解决了短沟道效应,而NanoSheet采用环绕栅极设计,实现了更强的静电控制与设计灵活性,结合EUV光刻技术,共同推动了芯片性能与能效的飞跃,为下一代AI与高性能计算奠定基石。

i3j4k5的博客 288

Java JDBC批处理 批量提交

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

LiuJie 的微博 4459

从零开始讲DDR(8)——AXI 接口MIG 使用(1)

我们简单拆解了MIG AXI接口中测试文件的整体框架,首先在sim_tb_top.sv文件中例化了DDR模型和example_top。在example_top中,又例化了MIG IP和一个流量产生器ddr4_v2_2_8_axi_tg_top。在ddr4_v2_2_8_axi_tg_top中的主要功能是分别例化了boot_mode_gen,prbs_mode_gen,custom_mode_gen和axi_opcode_gen。

apple_53311083的博客 1587

GIS常用符号化色带(超级色带)根据python制作

GIS自带的色带比较单一,今天分享一款色带,应用之后大家出图的时候可以选择更多的配色,符号化/点击色块/样式引用/将样式添加至列表即可。色带类型比较多,大家可以自己尝试下不同的风格。简单符号化一下,看看效果。以中国县级行政区划为例,

J_Giser的博客 2638

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

ICV:Metal Fill Insertion流程

如果不想删除先前加的metal fill,可以使用signoff_create_metal_fill -mode add命令,当使用这个mode后,工具不会fix density问题,哪怕设置了signoff.create_metal_fill.fix_density_errors,设置这个mode后可以使用以下option控制metal fill 的插入。默认情况下,signoff_create_metal_fill是会删掉已经加进去的metal/via fill再重新加的。

m0_61544122的博客 1133

Batch Processing

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

weixin_34211761的博客 201

游戏大厂技术护城河:你以为他们靠“美术和买量”,其实背后全是硬家伙

先把效果堆满到快上线了才发现低端机跑不动然后疯狂砍特效、降分辨率,画面崩、口碑崩机型分档(低/中/高)每帧预算(CPU/GPU 各多少 ms)每种资源预算(贴图、网格、粒子数量)性能自动回归(每天跑性能测试,发现波动立刻报警)大白话:小厂像装修到入住前才发现电路不够,临时拉线;大厂从设计图开始就算承重、算电路、算水压。玩家会不会来?活动会不会爆?版本会不会翻车?外挂会不会泛滥?竞品会不会抄?流量不确定 → 可扩容架构版本不确定 → 灰度与回滚。

本博客聚焦游戏开发技巧、创业实战心得及大学热门课程干货。这里既有技术深度,也有思维广度,无论你是开发者、创业者还是高校学子,都能在这里找到适合自己的成长之路! 104

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

jdbc 批量操作 batch

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

wangrong111222的博客 273

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

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

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

henry的专栏 4996

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

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

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

dreamoftch的专栏 1329

聊聊jdbc的batch操作

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

weixin_34132768的博客 475

JDBC batch批处理Statement executeBatch 详解

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

Base 8万+

设置ODBC的自定义类CSetODBC

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

闻缺陷则喜何志丹 3116
上一篇: 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、付费专栏及课程。

余额充值