<%@page contentType="text/html; charset=gbk"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.util.List"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.sql.Connection"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.*"%>
<%
///response.setContentType("text/html;charset=utf-8");
boolean hasLayOutData = false;
User user=(User)session.getAttribute(SessionConst.USER);
System.out.println(user.getUserGUID());
String layoutJson = (String)request.getParameter("layout");
layoutJson = java.net.URLDecoder.decode(layoutJson,"gbk");
String[] layouts = layoutJson.split(";");
Connection conn=null;
try {
conn=Conn.getConnection();
String cleanLayoutSql="delete from OFFICE_HOME_LAYOUT_BLOCK t where t.user_guid="+"'"+user.getUserGUID()+"'";
String sql = "INSERT INTO OFFICE_HOME_LAYOUT_BLOCK (ID, POSITION, LMMC,USER_GUID) VALUES(?,?,?,?)";
PreparedStatement prest = conn.prepareStatement(sql,ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
conn.setAutoCommit(false);
//Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
Statement stmt = conn.createStatement();
stmt.execute(cleanLayoutSql);
for(int i = 0; i < layouts.length; i++){
String[] values = layouts[i].split(",");
String[] layoutName = values[1].split(":");
String[] layoutPosition = values[2].split(":");
int position = Integer.parseInt(layoutPosition[1]);
System.out.println(new GUID()+":"+layoutPosition[1]+":"+layoutName[1]+":"+user.getUserGUID());
prest.setString(1, new GUID().toString());
prest.setInt(2, position);
prest.setString(3, layoutName[1]);
prest.setString(4, user.getUserGUID());
prest.addBatch();
} prest.executeBatch();
stmt.close();
conn.commit();
} catch (SQLException ex) {
ex.printStackTrace();
}catch (Exception ex) {
ex.printStackTrace();
} finally{
if(conn!=null )conn.close();
}
//System.out.println(layouts);
%>
Java批处理添加数据
最新推荐文章于 2024-05-03 11:46:59 发布