JFianl
1 得到当前的表中的最大的id值
/**
* 查询模板最大值
*/
private static long maxTpId() {
String url = “jdbc:mysql://220.178.51.188:2906/horce3”;
String username = “horce”;
String password = “horce@loday”;
DruidPlugin dbPlugin = new DruidPlugin(url, username, password);
dbPlugin.start();
//利用DbKit得到数据源的使用的权力 为使用Db准备
DbKit.setDataSource(dbPlugin.getDataSource());
//查询一个Long类型的数据
long maxId = Db.queryLong(“select max(id) from pod_circletemplates”);
dbPlugin.stop();
return maxId+1;
}
2 建立一个bean的list对象
public class TemplateDto{
;;;;;;;;;;;;;;
}
public class TemplateListDto implements Serializable {
private static final long serialVersionUID = 3191335902715268098L;
public List<TemplateDto> templateList = new ArrayList<TemplateDto>();
public List<TemplateDto> getTemplateDtoList() {
return templateList;
}
public void setTemplateList(List<TemplateDto> templateList) {
this.templateList = templateList;
}
}
3 插入数据到数据库的时候 没有任何的数据库连接的参数的时候
/**
* 插入数据库
*/
private static void excuteSQL(List sqlList) {
String url = “jdbc:mysql://220.178.51.188:2906/horce3”;
String username = “horce”;
String password = “horce@loday”;
DruidPlugin dbPlugin = new DruidPlugin(url, username, password);
dbPlugin.start();
//这2行的代码就是为Db得到相应的数据源
//DbKit.setDataSource(dbPlugin.getDataSource());
//long maxId = Db.queryLong(“select max(id) from pod_circletemplates”);
//此行代码的内部得到了数据源
Db.batch(dbPlugin.getDataSource(), sqlList, 1);
dbPlugin.stop();
}
4 java –> xml
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = “pic”)
@XmlType(propOrder = { “pagecontentid”, “infoid”, “contentflag”, “type”, “picid”, “x”, “y”, “angle”, “width”, “height”, “content”, “textstartnum”,
“textlenth”, “depth”, “bgcolor”, “fontDto”,”maskId”,”left”,”top”,”picWidth”,”picHeight”,”lines”})
public class UIContentDto implements Serializable {
private static final long serialVersionUID = 1L;
// @XmlAttribute(name="pagecontentid")
private long pagecontentid;// 页面元素id,唯一标识
// @XmlAttribute(name="infoid")
private long infoid;// 图片id或时光片id
// @XmlAttribute(name="contentflag")
private String contentflag;
@XmlAccessorType(XmlAccessType.FIELD) 所有的字段都会变成xml文件的节点
@XmlAccessorType(XmlAccessType.PROPERTY)
@XmlRootElement(name = "pic") pic 为xml文件的根节点
@XmlType 生成xml文件的时候的 节点的显示的顺序