本帖最后由 chyeers 于 2015-9-19 10:21 编辑
我使用 批处理一次性插入 ,但是有时候 phoenix 会爆出异常 [mw_shl_code=shell,true]org.apache.phoenix.exception.BatchUpdateExecution: ERROR 1106 (XCL06): Exception while executing batch[/mw_shl_code]
这样就丢失数据了,请问楼主遇到过么?
[mw_shl_code=scala,true] def toPhoenix(queue:mutable.Queue[Array[String]]): Unit = {
val manager:DBConnectionManager = DBConnectionManager.getInstance()
val conn:Connection = manager.getConnection("phoenix")
var ps: PreparedStatement = null
var flag:Boolean = false
val sql = "UPSERT INTO DATA.LOG VALUES(?,?,?,?,?)"
try{
ps = conn.prepareStatement(sql)
for(i<- 0 to queue.length-1){
ps.setString(1, queue(i)(0))
ps.setString(2, queue(i)(1))
ps.setString(3, queue(i)(2))
ps.setString(4, queue(i)(3))
ps.setString(5, queue(i)(4))
ps.addBatch()
}
ps.executeBatch()
conn.commit()
flag = true
}catch {
case e: Exception => print(e)
......[/mw_shl_code]
|