jdbc in postgres
try {
Class.forName("org.postgresql.Driver").newInstance();
String url = "jdbc:postgresql://localhost:5432/erp";
String user = "xx";
String pwd = "xx";
Connection conn = DriverManager.getConnection(url, user, pwd);
Statement st = conn.createStatement();
ResultSet rs = st.executeQuery("SELECT * FROM goods_picture where md5 is null");
List<String> paths = new ArrayList<String>();
int i = 0;
while (rs.next()) {
i++;
LOGGER.debug(rs.getString(1));//id
LOGGER.debug(rs.getString(2));//goodsid
LOGGER.debug(rs.getString(3));//seqno
LOGGER.debug(rs.getString(4));//picturetypeid
LOGGER.debug(rs.getString(5));//title
LOGGER.debug(rs.getString(6));//path
paths.add(rs.getString(6));
LOGGER.debug(rs.getString(7));//companyid
LOGGER.debug(rs.getString(8));
LOGGER.debug(rs.getString(9));
LOGGER.debug(rs.getString(10));
}
LOGGER.debug("total:"+i);
rs.close();
st.close();
//批量更新
conn.setAutoCommit(false);
Statement stmt =conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
for(int x = 0; x < paths.size();x++){
String path = paths.get(x);
String md5 = ImageMigrator.readAndUpload(null,path);
if(md5!=null){
stmt.addBatch("update goods_picture set md5='"+md5+"' where path='"+path+"'");
}
}
stmt.executeBatch();
conn.commit();
stmt.close();
conn.close();
} catch (Exception e) {
e.printStackTrace();
}
}
jdbc in postgres的更多相关文章
- oracle ,mysql,postgres jdbc配置文件
#db mysql #jdbc.driver=com.mysql.jdbc.Driver #jdbc.url=jdbc:mysql://localhost:3306/mysql?&useUni ...
- 数据库jdbc链接:mysql, oracle, postgresql
#db mysql#jdbc.driver=com.mysql.jdbc.Driver#jdbc.url=jdbc:mysql://localhost:3306/mysql?&useUnico ...
- Docker + Sonarqube 环境搭建
Sonar概述 Sonar 是一个用于代码质量管理的开放平台.通过插件机制,Sonar 可以集成不同的测试工具,代码分析工具,以及持续集成工具. 一,postgres 数据库下载 docker pul ...
- nakadi-ui nakadi event broker 的可视化UI工具
nakadi 是一款很不错的基于fafka 开发的event broker ,我们只需要使用http 请求就可以调用kafka 方便的发布订阅功能 环境准备 docker-compose 文件 ver ...
- nakadi 一款基于kafka 的http event broker
nakadi 是zalando 开源的一款基于kafka 的event broker ,我们可以方便的使用http 协议进行操作 支持一些特性: stream 操作,我们可以流的方式订阅event e ...
- sqlserver修改为windows验证登陆, 程序的调整
业务需求, 客户要求sqlserver改为windows验证登陆, sa用户不可用, 程序端如何修改呢? 我在本机做了个测试. 环境: sqlserver2016, springmvc+spring+ ...
- saga+.net core 分布式事务处理
Apache ServiceComb Saga 是一个微服务应用的数据最终一致性解决方案 中文官方地址:https://github.com/apache/servicecomb-saga/blob/ ...
- SonarQube install on Kubernetes
Sonarqube搭建代码 apiVersion: extensions/v1beta1 kind: Deployment metadata: name: postgres labels: app: ...
- wildfly配置PostgreSQL数据源
wildfly配置PostgreSQL数据源 很久以前写过在JBoss AS7上如何配置PostgreSQL数据源,此方法在wildfly上依然有效.不过,通过wildfly的命令行工具可以有更简单的 ...
随机推荐
- Qt中修改QtoolTip的样式
Qt中的QtoolTip有几个需要注意的: 1.不能直在堆或栈中生成QToolTip对象.因为其构造函数为私有.2.从widget获取的tooltip不是tooltip对象,而是tooltip中的文本 ...
- HDU 3966 Aragorn's Story 树链拋分
一.写在前面 终于开始开坑link-cut-tree这个了,对于网上找到的大佬的前进路线,进行了一番研发,发现实际上可以实现对于树链拋分的制作.经历了若干长时间之后终于打了出来(为什么每次学什么东西都 ...
- AngularJS 之1-初识
摘要:本文主要记录第一次接触AngularJS的笔记,现在在我面前就是一张白纸+一点简单的html知识. 1.首先在<head>中加 <script src="一个网址(具 ...
- Three Steps to Migrate Group Policy Between Active Directory Domains or Forests Using PowerShell
Three Steps Ahead Have you ever wished that you had three legs? Imagine how much faster you could ru ...
- 设计模式之第17章-备忘录模式(Java实现)
设计模式之第17章-备忘录模式(Java实现) 好男人就是我,我就是曾小贤.最近陈赫和张子萱事件闹得那是一个沸沸扬扬.想想曾经每年都有爱情公寓陪伴的我现如今过年没有了爱情公寓总是感觉缺少点什么.不知道 ...
- IOS开发学习笔记015-block和protocol
一.block block 代码段 标识是 ^ block 和函数很像 1.可以保存代码 2.有返回值 3.有形参 格式 返回值 (block名)(形参列表) = ^(形参列表) {代码段 ...
- 【原创】React实例入门教程(1)基础API,JSX语法--hello world
前 言 毫无疑问,react是目前最最热门的框架(没有之一),了解并学习使用React,可以说是现在每个前端工程师都需要的. 在前端领域,一个框架为何会如此之火爆,无外乎两个原因:性能优秀,开发效率 ...
- Leetcode 632.最小区间
最小区间 你有 k 个升序排列的整数数组.找到一个最小区间,使得 k 个列表中的每个列表至少有一个数包含在其中. 我们定义如果 b-a < d-c 或者在 b-a == d-c 时 a < ...
- 使用anaconda
Please run $ source /opt/anaconda/bin/activate root $ source /opt/anaconda/bin/deactivate root to ...
- 构建乘积数组--java
题目:给定一个数组A[0,1,...,n-1],请构建一个数组B[0,1,...,n-1],其中B中的元素B[i]=A[0]*A[1]*...*A[i-1]*A[i+1]*...*A[n-1].不能使 ...