cmd命令执行的数据清洗工具
2018-02-11 16:59
302 查看
最近,接一个需求,要求清洗存量数据,开发一个可以打印日志的小程序。
经过多天的实验,最终采用mybatis的操作数据库方式,cmd中执行 java -jar clear.jar,来执行方法清洗数据库数据。
第一步,创建一个java project 命名为cleaner
第二步,在src目录下,创建mapper.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="mapper">
<!--根据关联项目表,获取全部数据 -->
<select id="selectDsqpIP" resultType="vo.DsqpInterPlanInfo">
select a.* from dsqp_inter_plan_info a ,dsqp_inter_pro_info b where a.pro_uuid=b.pkid and a.hs_summary='投产'
</select>
<!--根据关联项目表,获取全部数据 -->
<select id="selectPlan" parameterType="String" resultType="vo.ApmProInfo">
select * from apm_pro_info b where b.inter_pro_info_pkid=#{id}
</select>
<!--更新apm_pro_info表数据 -->
<update id="updateOneApmProInfo" parameterType="vo.EmpAndExtend">
update apm_pro_info set operate_date=#{endDate} where inter_pro_info_pkid=#{projectid}
</update>
<!--根据关联项目表,获取全部数据 -->
<select id="selectDsqpInterProInfo" resultType="vo.DsqpInterProInfo">
select * from
dsqp_inter_pro_info
</select>
<!--根据关联开发项目的pkid查询相关联的创建的测试项目 -->
<select id="selectApmProInfo" parameterType="String" resultType="vo.ApmProInfo">
select * from apm_pro_info where inter_pro_info_pkid=#{id}
</select>
<!--根据关联开发项目的pkid查询相关联的创建的测试项目 -->
<select id="ApmProExtend" parameterType="int" resultType="vo.ApmProExtend">
select
* from apm_pro_proextend where proid=#{id}
</select>
<!--根据关联开发项目的所属中心查询组织表的orgid、orgname -->
<select id="Organization" parameterType="String" resultType="vo.Organization">
select * from org_organization where orgname=#{center}
</select>
<!--根据所属中心和pm查询 hfuser和 org_employee -->
<select id="EmpAndExtend" parameterType="String" resultType="vo.EmpAndExtend">
select a.userno,a.username,c.empid from dsqp_hf_user a,org_employee c
where a.userno=c.empcode and a.blngbrchnm=#{project_center} and
a.username=#{pm}
</select>
<!-- 插入apm_pro_proextend表数据 -->
<!--在ibatis中不需要关注这些参数 而转到mybatis后 如果字段值为空 必须设置jdbcType -->
<insert id="insertOne" parameterType="vo.ApmProExtend">
insert into
apm_pro_proextend values
(#{proid,jdbcType=NUMERIC},#{orgid,jdbcType=NUMERIC},#{orgname,jdbcType=VARCHAR},#{empid,jdbcType=VARCHAR},
#{empname,jdbcType=VARCHAR},#{userid,jdbcType=VARCHAR},#{num,jdbcType=INTEGER})
</insert>
<!--更新apm_pro_proextend表数据 -->
<update id="updateOne" parameterType="vo.ApmProExtend">
update apm_pro_proextend
<trim prefix="set" suffixOverrides=",">
<if test="empid!=null">empid=#{empid},</if>
<if test="empname!=null">empname=#{empname},</if>
<if test="userid!=null">userid=#{userid},</if>
<if test="orgid!=null">orgid=#{orgid},</if>
<if test="orgname!=null">orgname=#{orgname},</if>
</trim>
WHERE proid=#{proid}
</update>
</mapper>
第四步:src在创建mybatisConf.xml;
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<properties resource="dataSource.properties" />
<environments default="development">
<environment id="development">
<transactionManager type="jdbc" />
<dataSource type="pooled">
<property name="driver" value="${driver}" />
<property name="url" value="${url}" />
<property name="username" value="${username}" />
<property name="password" value="${password}" />
</dataSource>
</environment>
</environments>
<mappers>
<mapper resource="mapper.xml" />
</mappers>
</configuration>
第五步:dataSource.properties;
url=jdbc:oracle:thin:@xxx.xxx.xxx.xxx:1521:orcl
username=xxxx
password =xxxx
driver=oracle.jdbc.driver.OracleDriver
第六步:创建vo实体类;
第七步:编写services的main方法
第八步:点击左侧项目名,右键选择export-->runnable jar file-->launch configuration -->选择main主方法,library handling-->如果有引用第三方jar包选择copy required libraries into a sub-folder next to the generated jar.-->finish
第九步:cmd 进入到打包所在的路径下,执行java -jar 打包名.jar;
完美启动;
经过多天的实验,最终采用mybatis的操作数据库方式,cmd中执行 java -jar clear.jar,来执行方法清洗数据库数据。
第一步,创建一个java project 命名为cleaner
第二步,在src目录下,创建mapper.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="mapper">
<!--根据关联项目表,获取全部数据 -->
<select id="selectDsqpIP" resultType="vo.DsqpInterPlanInfo">
select a.* from dsqp_inter_plan_info a ,dsqp_inter_pro_info b where a.pro_uuid=b.pkid and a.hs_summary='投产'
</select>
<!--根据关联项目表,获取全部数据 -->
<select id="selectPlan" parameterType="String" resultType="vo.ApmProInfo">
select * from apm_pro_info b where b.inter_pro_info_pkid=#{id}
</select>
<!--更新apm_pro_info表数据 -->
<update id="updateOneApmProInfo" parameterType="vo.EmpAndExtend">
update apm_pro_info set operate_date=#{endDate} where inter_pro_info_pkid=#{projectid}
</update>
<!--根据关联项目表,获取全部数据 -->
<select id="selectDsqpInterProInfo" resultType="vo.DsqpInterProInfo">
select * from
dsqp_inter_pro_info
</select>
<!--根据关联开发项目的pkid查询相关联的创建的测试项目 -->
<select id="selectApmProInfo" parameterType="String" resultType="vo.ApmProInfo">
select * from apm_pro_info where inter_pro_info_pkid=#{id}
</select>
<!--根据关联开发项目的pkid查询相关联的创建的测试项目 -->
<select id="ApmProExtend" parameterType="int" resultType="vo.ApmProExtend">
select
* from apm_pro_proextend where proid=#{id}
</select>
<!--根据关联开发项目的所属中心查询组织表的orgid、orgname -->
<select id="Organization" parameterType="String" resultType="vo.Organization">
select * from org_organization where orgname=#{center}
</select>
<!--根据所属中心和pm查询 hfuser和 org_employee -->
<select id="EmpAndExtend" parameterType="String" resultType="vo.EmpAndExtend">
select a.userno,a.username,c.empid from dsqp_hf_user a,org_employee c
where a.userno=c.empcode and a.blngbrchnm=#{project_center} and
a.username=#{pm}
</select>
<!-- 插入apm_pro_proextend表数据 -->
<!--在ibatis中不需要关注这些参数 而转到mybatis后 如果字段值为空 必须设置jdbcType -->
<insert id="insertOne" parameterType="vo.ApmProExtend">
insert into
apm_pro_proextend values
(#{proid,jdbcType=NUMERIC},#{orgid,jdbcType=NUMERIC},#{orgname,jdbcType=VARCHAR},#{empid,jdbcType=VARCHAR},
#{empname,jdbcType=VARCHAR},#{userid,jdbcType=VARCHAR},#{num,jdbcType=INTEGER})
</insert>
<!--更新apm_pro_proextend表数据 -->
<update id="updateOne" parameterType="vo.ApmProExtend">
update apm_pro_proextend
<trim prefix="set" suffixOverrides=",">
<if test="empid!=null">empid=#{empid},</if>
<if test="empname!=null">empname=#{empname},</if>
<if test="userid!=null">userid=#{userid},</if>
<if test="orgid!=null">orgid=#{orgid},</if>
<if test="orgname!=null">orgname=#{orgname},</if>
</trim>
WHERE proid=#{proid}
</update>
</mapper>
第四步:src在创建mybatisConf.xml;
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<properties resource="dataSource.properties" />
<environments default="development">
<environment id="development">
<transactionManager type="jdbc" />
<dataSource type="pooled">
<property name="driver" value="${driver}" />
<property name="url" value="${url}" />
<property name="username" value="${username}" />
<property name="password" value="${password}" />
</dataSource>
</environment>
</environments>
<mappers>
<mapper resource="mapper.xml" />
</mappers>
</configuration>
第五步:dataSource.properties;
url=jdbc:oracle:thin:@xxx.xxx.xxx.xxx:1521:orcl
username=xxxx
password =xxxx
driver=oracle.jdbc.driver.OracleDriver
第六步:创建vo实体类;
第七步:编写services的main方法
第八步:点击左侧项目名,右键选择export-->runnable jar file-->launch configuration -->选择main主方法,library handling-->如果有引用第三方jar包选择copy required libraries into a sub-folder next to the generated jar.-->finish
第九步:cmd 进入到打包所在的路径下,执行java -jar 打包名.jar;
完美启动;
相关文章推荐
- C#程序调用cmd执行命令-MySql备份还原
- java执行windows 的cmd 命令说明
- windows7 64bit下mvn命令后提示‘cmd’不是内部或外部命令,也不是可执行程序或批处理文件
- C#代码打开CMD.EXE 执行 DIR命令,并接收返回值
- [转] 打开 CMD 时自动执行命令
- 关于cmd中执行命令路径包含空格的解决办法
- C# WINForm 如何关闭系统进程,调用cmd并执行命令(隐藏CMD窗口) - 赤色火焰 - 京华志
- java本地调用cmd,shell命令,远程调用Linux执行命令方法总结
- c# 调用CMD命令执行dos命令
- commix命令执行利用工具
- .NET执行cmd时,如何调试命令的执行效果
- 使用批处理文件同时打多个CMD窗口且执行多条命令
- windows下如何打开cmd窗口就能执行redis的相关命令
- window执行cmd不是内部命令
- 数据清洗工具OpenRefine
- SQL命令:清除数据缓存和执行计划缓存,查看执行计划
- 数 4000 据库备份 runtime.exec 去执行命令 返回 process 读取process的输入流 把数据写入执行文件里
- 数据库:用cmd命令导dmp数据
- windows从cmd中键入命令的一些常用小工具