锘??xml version="1.0" encoding="utf-8" standalone="yes"?>av在线不卡一区,在线综合欧美,电影亚洲一区http://www.aygfsteel.com/banxitan/category/53406.htmlzh-cnWed, 13 Mar 2013 12:41:00 GMTWed, 13 Mar 2013 12:41:00 GMT60MySql 鐨勬壒閲忔搷浣滐紝瑕佸姞rewriteBatchedStatements鍙傛暟 http://www.aygfsteel.com/banxitan/archive/2013/03/13/396409.htmlMikyTanMikyTanWed, 13 Mar 2013 12:38:00 GMThttp://www.aygfsteel.com/banxitan/archive/2013/03/13/396409.htmlhttp://www.aygfsteel.com/banxitan/comments/396409.htmlhttp://www.aygfsteel.com/banxitan/archive/2013/03/13/396409.html#Feedback0http://www.aygfsteel.com/banxitan/comments/commentRss/396409.htmlhttp://www.aygfsteel.com/banxitan/services/trackbacks/396409.html浠婂ぉ鍦ㄥ仛鏌愰」鐩殑POC嫻嬭瘯錛岀敳鏂規彁渚涗簡涓涓笁鍗佷竾璁板綍鐨凾XT鏁版嵁鏂囦歡錛岄渶瑕佹妸璇ユ枃浠剁殑璁板綍鎻掑叆鍒版暟鎹簱涓紝鐢變簬欏圭洰閮ㄧ殑鍚屼簨鍦ㄦ惌寤烘祴璇曠幆澧冧腑鐢ㄧ殑鏄疢ysql鏁版嵁搴擄紝鍦ㄦ妸鏁版嵁瀵煎叆鍒版暟鎹簱涓敤鐨勬槸JDBC鐨勬壒澶勭悊銆備唬鐮佸涓?
private void batchParseGroup(){
        Connection con
= null;
        PreparedStatement ps 
=null;
        
try {
            con
= DbConnectionManager.getConnection();
            con.setAutoCommit(
false);
            String sql 
= " insert into jivegroup(uri,groupname,pgroupid,description,creationdate,modificationdate,priority,selfpriority) values(?,?,?,?,?,?,?,?)";
            ps
= con.prepareStatement(sql);
            
for(int i=0;i<groupList.size();i++){
                Group group 
= groupList.get(i);
                ps.setString(
1, group.getUri());
                ps.setString(
2, group.getName());
                ps.setString(
3, group.getPgroupId());
                ps.setString(
4, group.getName());
                ps.setString(
5""+System.currentTimeMillis());
                ps.setString(
6""+System.currentTimeMillis());
                ps.setInt(
7, group.getPriority());
                ps.setInt(
8, group.getPriority());
                ps.addBatch();
                
if(i%100==0){
                    ps.executeBatch();
                }

            }

            con.commit();
            ps.executeBatch();
        }
 catch (SQLException e) {
            e.printStackTrace();
        }
finally{
            DbConnectionManager.closeConnection(ps, con);
        }

    }

鍦ㄦ祴璇曟椂錛屽彂鐜頒笁鍗佷竾鐨勬暟鎹眳鐒墮渶瑕佸崄鍒嗛挓宸﹀彸鐨勬椂闂淬傞鍏堟兂鍒扮殑灝辨槸Mysql鐨勭浉鍏抽厤緗槸涓嶆槸鏈夐棶棰橈紝鍙嶅淇敼浜哅ysql鐨勭浉搴旈厤緗弬鏁幫紝鏀舵晥鐢氬井銆?br />
鍦∕ysql鐨勫畼緗戜笂鏌ュ埌濡備笅錛?br /> http://dev.mysql.com/doc/refman/5.1/en/connector-j-reference-configuration-properties.html

鍏充簬rewriteBatchedStatements鍙傛暟錛孧ysql瀹樻柟鐨勮鏄庯細

Should the driver use multiqueries (irregardless of the setting of "allowMultiQueries") as well as rewriting of prepared statements for INSERT into multi-value inserts when executeBatch() is called? Notice that this has the potential for SQL injection if using plain java.sql.Statements and your code doesn't sanitize input correctly. Notice that for prepared statements, server-side prepared statements can not currently take advantage of this rewrite option, and that if you don't specify stream lengths when using PreparedStatement.set*Stream(), the driver won't be able to determine the optimum number of parameters per batch and you might receive an error from the driver that the resultant packet is too large. Statement.getGeneratedKeys() for these rewritten statements only works when the entire batch includes INSERT statements.



瑙e喅鍔炴硶錛?br />      涓嬭澆鏈鏂扮殑JDBC鐨勯┍鍔ㄧ▼搴忋?br />      MYSQL URL鐨勯厤緗弬鏁板涓嬶細
      jdbc:mysql://54.200.190.80:3306/ccb_ucstar?rewriteBatchedStatements=true

緇忚繃嫻嬭瘯銆備笁鍗佸涓囩殑鏁版嵁銆?0縐掑唴鎼炲畾錛?/div>

MikyTan 2013-03-13 20:38 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 维西| 改则县| 清河县| 镇康县| 旬阳县| 曲阜市| 淮滨县| 宣武区| 厦门市| 达州市| 甘孜| 逊克县| 乐业县| 克拉玛依市| 会理县| 芮城县| 葫芦岛市| 白城市| 永济市| 特克斯县| 嘉兴市| 冀州市| 玉门市| 山阳县| 富顺县| 依安县| 沙湾县| 西平县| 北票市| 铜梁县| 兰溪市| 万宁市| 广丰县| 巴中市| 阳原县| 梁平县| 萨嘎县| 科技| 绍兴县| 清流县| 井冈山市|