/** * 按图片类型查询图片信息 * * @param String * @return List<LEDPicSchema> */ public List<LEDPicSchema> find(String typeCode) { List<LEDPicSchema> listLEDPicSchema = new ArrayList<LEDPicSchema>(); ExeSQL mExeSQL = new ExeSQL(); String sql = "select * from ledpic where typecode=? "; String[] param1 = {"String", typeCode}; ArrayList<String[]> sqlParamList = new ArrayList<String[]>(); sqlParamList.add(param1); SSRS tSSRS = mExeSQL.execSQL(sql, sqlParamList); if (tSSRS != null || tSSRS.MaxRow > 0) { for (int i = 1; i <= tSSRS.MaxRow; i++) { LEDPicSchema tLEDPicSchema = new LEDPicSchema(); tLEDPicSchema.setPicCode(tSSRS.getRowData(i)[0]); tLEDPicSchema.setName(tSSRS.getRowData(i)[1]); tLEDPicSchema.setTypecode(tSSRS.getRowData(i)[2]); tLEDPicSchema.setUseFlag(tSSRS.getRowData(i)[3]); tLEDPicSchema.setField1(tSSRS.getRowData(i)[4]); tLEDPicSchema.setField2(tSSRS.getRowData(i)[5]); tLEDPicSchema.setField3(tSSRS.getRowData(i)[6]); tLEDPicSchema.setMakeDate(tSSRS.getRowData(i)[7]); tLEDPicSchema.setMakeTime(tSSRS.getRowData(i)[8]); listLEDPicSchema.add(tLEDPicSchema); } return listLEDPicSchema; } return null; }
/** 检查数据库中是否只剩下一条此类型的图片数据信息 true--只剩下一条,false--不只有一条 */ public boolean onlyOne(LEDPicSchema tLEDPicSchema) { ExeSQL mExeSQL = new ExeSQL(); String sql = "select * from ledpic where typecode= ? "; String[] param1 = {"String", tLEDPicSchema.getTypecode()}; ArrayList<String[]> sqlParamList = new ArrayList<String[]>(); sqlParamList.add(param1); SSRS tSSRS = mExeSQL.execSQL(sql, sqlParamList); if (tSSRS == null || tSSRS.MaxRow <= 1) { return true; } return false; }
/** * 新增图片信息 * * @param LEDPicSchema * @return boolean */ public boolean add(LEDPicSchema tLEDPicSchema) { ExeSQL mExeSQL = new ExeSQL(); StringBuffer sqlbuf = new StringBuffer(); sqlbuf.append("insert into ledpic values("); sqlbuf.append("?,"); sqlbuf.append("?,"); sqlbuf.append("?,"); sqlbuf.append("?,"); sqlbuf.append("?,"); sqlbuf.append("?,"); sqlbuf.append("?,"); sqlbuf.append("?,"); sqlbuf.append("?)"); ArrayList<String[]> list = new ArrayList<String[]>(); String[] arr = new String[2]; arr[0] = "String"; arr[1] = tLEDPicSchema.getPicCode(); list.add(arr); arr = new String[2]; arr[0] = "String"; arr[1] = tLEDPicSchema.getName(); list.add(arr); arr = new String[2]; arr[0] = "String"; arr[1] = tLEDPicSchema.getTypecode(); list.add(arr); arr = new String[2]; arr[0] = "String"; arr[1] = tLEDPicSchema.getUseFlag(); list.add(arr); arr = new String[2]; arr[0] = "String"; arr[1] = tLEDPicSchema.getField1(); list.add(arr); arr = new String[2]; arr[0] = "String"; arr[1] = tLEDPicSchema.getField2(); list.add(arr); arr = new String[2]; arr[0] = "String"; arr[1] = tLEDPicSchema.getField3(); list.add(arr); arr = new String[2]; arr[0] = "String"; arr[1] = tLEDPicSchema.getMakeDate(); list.add(arr); arr = new String[2]; arr[0] = "String"; arr[1] = tLEDPicSchema.getMakeTime(); list.add(arr); if (!mExeSQL.execUpdateSQL(sqlbuf.toString(), list)) { System.out.println("图片保存过程出现错误!"); return false; } System.out.println("图片保存成功!"); return true; }