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 =NewArraylist<string>(); inti = 0; while(Rs.next ()) {i++; Logger.debug (Rs.getstring (1));//IDLogger.debug (rs.getstring (2));//GoodsidLogger.debug (Rs.getstring (3));//seqnoLogger.debug (Rs.getstring (4));//PicturetypeidLogger.debug (Rs.getstring (5));//titleLogger.debug (rs.getstring (6));//PathPaths.add (rs.getstring (6)); Logger.debug (Rs.getstring (7));//CompanyIDLogger.debug (Rs.getstring (8)); Logger.debug (Rs.getstring (9)); Logger.debug (Rs.getstring (10)); } logger.debug ("Total:" +i); Rs.close (); St.close (); //Batch UpdateConn.setautocommit (false); Statement stmt=conn.createstatement (resultset.type_scroll_sensitive,resultset.concur_read_only); for(intx = 0; × < 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