622d47cceceb441fd73797e689487b0cff435fa3.svn-base 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518
  1. package com.sinosoft.lz.unitsWH.unitsWHDAO;
  2. import java.sql.Connection;
  3. import java.sql.PreparedStatement;
  4. import java.sql.ResultSet;
  5. import java.sql.SQLException;
  6. import org.apache.log4j.Logger;
  7. import com.persistence.DbConnection;
  8. import com.sinosoft.em.alert.response.service.ResponseService;
  9. public class unitsWHDAO {
  10. //日志对象
  11. private static final Logger log = Logger.getLogger(ResponseService.class);
  12. public String getAllUnitShow1(String corpId,String butVal){//查询本单位------根结点(初次加载)
  13. //dept_id='corp_id'
  14. // String sql="select DEPT_ID,DEPT_NAME,PARENT_ID,DEPT_TYPE from SYS_DEPARTMENT where DEPT_ID='"+corpId+"' and CODES_ISSHOW like '%'|| (select fd_code from bm_mapvaluecanst where fd_description='"+butVal+"') ||'%' order by SORT";
  15. String fdcode = getFdcodeByFddesc(butVal);
  16. String sql="select DEPT_ID,DEPT_NAME,PARENT_ID,DEPT_TYPE from SYS_DEPARTMENT where DEPT_ID='"+corpId+"' and CODES_ISSHOW like '%"+fdcode+"%' order by SORT";
  17. // String sql="select DEPT_ID,DEPT_NAME,PARENT_ID,DEPT_TYPE from SYS_DEPARTMENT where DEPT_ID='"+corpId+"' order by SORT";
  18. StringBuffer sb = new StringBuffer();
  19. DbConnection dbConn = new DbConnection();
  20. Connection conn = null;
  21. PreparedStatement pstm = null;
  22. ResultSet rs = null;
  23. try {
  24. conn = dbConn.getConnection();
  25. pstm = conn.prepareStatement(sql);
  26. // pstm.setString(1, butVal);
  27. rs = pstm.executeQuery();
  28. while(rs.next()){
  29. String dept_id = rs.getString("DEPT_ID") == null ? "" : rs.getString("DEPT_ID");//单位ID
  30. String dept_name = rs.getString("DEPT_NAME") == null ? "" : rs.getString("DEPT_NAME");//单位NAME
  31. String parent_id = rs.getString("PARENT_ID") == null ? "" : rs.getString("PARENT_ID");//上级单位ID
  32. String dept_type = rs.getString("DEPT_TYPE") == null ? "" : rs.getString("DEPT_TYPE");//单位类型(单位--=1,部门--!=1)
  33. //根结点
  34. sb.append("{\"id\":\""+dept_id+"\",\"name\":\""+dept_name+"\",\"parentId\":\"0\",\"open\":\"true\",\"isParent\":\"true\",\"icon\":\"/nwyj/scripts/qui/libs/icons/home.png\",\"orgLevel\":\"null\"},");
  35. //下级部门
  36. // sb.append("{\"id\":\""+dept_id+";1"+"\",\"name\":\"本部\",\"parentId\":\""+dept_id+"\",\"open\":\"false\",\"isParent\":\"true\",\"icon\":\"/nwyj/scripts/qui/libs/icons/home.png\",\"orgLevel\":\"null\"},");
  37. sb.append(getAllUnitShow3(dept_id,butVal));
  38. //下级单位
  39. sb.append(getAllUnitShow2(dept_id,butVal));
  40. }
  41. if(sb.lastIndexOf(",")>-1){
  42. sb.deleteCharAt(sb.lastIndexOf(","));
  43. }
  44. } catch (ClassNotFoundException e) {
  45. // TODO Auto-generated catch block
  46. e.printStackTrace();
  47. } catch (SQLException e) {
  48. // TODO Auto-generated catch block
  49. e.printStackTrace();
  50. }finally{
  51. try {
  52. if(rs!=null)
  53. rs.close();
  54. if(pstm!=null)
  55. pstm.close();
  56. if(conn!=null)
  57. conn.close();
  58. } catch (SQLException e) {
  59. // TODO Auto-generated catch block
  60. e.printStackTrace();
  61. }
  62. }
  63. // System.out.println("111111111111111111111111"+sb.toString());
  64. return sb.toString();
  65. }
  66. public String getAllUnitShow5(String corpId,String butVal){//查询本单位------根结点(初次加载)
  67. //dept_id='corp_id'
  68. // String sql="select DEPT_ID,DEPT_NAME,PARENT_ID,DEPT_TYPE from SYS_DEPARTMENT where DEPT_ID='"+corpId+"' and CODES_ISSHOW like '%'|| (select fd_code from bm_mapvaluecanst where fd_description='"+butVal+"') ||'%' order by SORT";
  69. // String fdcode = getFdcodeByFddesc(butVal);
  70. // String sql="select DEPT_ID,DEPT_NAME,PARENT_ID,DEPT_TYPE from SYS_DEPARTMENT where DEPT_ID='"+corpId+"' and CODES_ISSHOW like '%"+fdcode+"%' order by SORT";
  71. String sql="select DEPT_ID,DEPT_NAME,PARENT_ID,DEPT_TYPE from SYS_DEPARTMENT where DEPT_ID='"+corpId+"' order by SORT";
  72. StringBuffer sb = new StringBuffer();
  73. DbConnection dbConn = new DbConnection();
  74. Connection conn = null;
  75. PreparedStatement pstm = null;
  76. ResultSet rs = null;
  77. try {
  78. conn = dbConn.getConnection();
  79. pstm = conn.prepareStatement(sql);
  80. // pstm.setString(1, butVal);
  81. rs = pstm.executeQuery();
  82. while(rs.next()){
  83. String dept_id = rs.getString("DEPT_ID") == null ? "" : rs.getString("DEPT_ID");//单位ID
  84. String dept_name = rs.getString("DEPT_NAME") == null ? "" : rs.getString("DEPT_NAME");//单位NAME
  85. String parent_id = rs.getString("PARENT_ID") == null ? "" : rs.getString("PARENT_ID");//上级单位ID
  86. String dept_type = rs.getString("DEPT_TYPE") == null ? "" : rs.getString("DEPT_TYPE");//单位类型(单位--=1,部门--!=1)
  87. //根结点
  88. sb.append("{\"id\":\""+dept_id+"\",\"name\":\""+dept_name+"\",\"parentId\":\"0\",\"open\":\"true\",\"isParent\":\"true\",\"icon\":\"/nwyj/scripts/qui/libs/icons/home.png\",\"orgLevel\":\"null\"},");
  89. //下级部门
  90. // sb.append("{\"id\":\""+dept_id+";1"+"\",\"name\":\"本部\",\"parentId\":\""+dept_id+"\",\"open\":\"false\",\"isParent\":\"true\",\"icon\":\"/nwyj/scripts/qui/libs/icons/home.png\",\"orgLevel\":\"null\"},");
  91. sb.append(getAllUnitShow3(dept_id,butVal));
  92. //下级单位
  93. sb.append(getAllUnitShow2(dept_id,butVal));
  94. }
  95. if(sb.lastIndexOf(",")>-1){
  96. sb.deleteCharAt(sb.lastIndexOf(","));
  97. }
  98. } catch (ClassNotFoundException e) {
  99. // TODO Auto-generated catch block
  100. e.printStackTrace();
  101. } catch (SQLException e) {
  102. // TODO Auto-generated catch block
  103. e.printStackTrace();
  104. }finally{
  105. try {
  106. if(rs!=null)
  107. rs.close();
  108. if(pstm!=null)
  109. pstm.close();
  110. if(conn!=null)
  111. conn.close();
  112. } catch (SQLException e) {
  113. // TODO Auto-generated catch block
  114. e.printStackTrace();
  115. }
  116. }
  117. // System.out.println("111111111111111111111111"+sb.toString());
  118. return sb.toString();
  119. }
  120. public String getAllUnitShow4(String corpId,String butVal){//查询本单位------根结点(非初次)
  121. StringBuffer sb = new StringBuffer();
  122. //下级部门
  123. // int n = corpId.split(";").length;
  124. // System.out.println("***/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/**8888888888888888888888888888----"+n+"--:"+corpId);
  125. // if(n<2){
  126. // sb.append("{\"id\":\""+corpId+";1"+"\",\"name\":\"本部\",\"parentId\":\""+corpId+"\",\"open\":\"false\",\"isParent\":\"true\",\"icon\":\"/nwyj/scripts/qui/libs/icons/home.png\",\"orgLevel\":\"null\"},");
  127. // }
  128. sb.append(getAllUnitShow3(corpId,butVal));
  129. //下级单位
  130. sb.append(getAllUnitShow2(corpId,butVal));
  131. if(sb.lastIndexOf(",")>-1){
  132. sb.deleteCharAt(sb.lastIndexOf(","));
  133. }
  134. return sb.toString();
  135. }
  136. public String getAllUnitShow2(String deptId,String butVal){//查询下级所有单位------(非部门)
  137. String fdcode = getFdcodeByFddesc(butVal);
  138. String sql="select DEPT_ID,DEPT_NAME,PARENT_ID,DEPT_TYPE from SYS_DEPARTMENT where PARENT_ID='"+deptId+"' and DEPT_TYPE='1' and CODES_ISSHOW like '%"+fdcode+"%' order by SORT";
  139. // String sql="select DEPT_ID,DEPT_NAME,PARENT_ID,DEPT_TYPE from SYS_DEPARTMENT where PARENT_ID='"+deptId+"' and DEPT_TYPE='1' order by SORT";
  140. StringBuffer sb = new StringBuffer();
  141. DbConnection dbConn = new DbConnection();
  142. Connection conn = null;
  143. PreparedStatement pstm = null;
  144. ResultSet rs = null;
  145. try {
  146. conn = dbConn.getConnection();
  147. pstm = conn.prepareStatement(sql);
  148. // pstm.setString(1, butVal);
  149. rs = pstm.executeQuery();
  150. while(rs.next()){
  151. String dept_id = rs.getString("DEPT_ID") == null ? "" : rs.getString("DEPT_ID");//单位ID
  152. String dept_name = rs.getString("DEPT_NAME") == null ? "" : rs.getString("DEPT_NAME");//单位NAME
  153. String parent_id = rs.getString("PARENT_ID") == null ? "" : rs.getString("PARENT_ID");//上级单位ID
  154. String dept_type = rs.getString("DEPT_TYPE") == null ? "" : rs.getString("DEPT_TYPE");//单位类型(单位--=1,部门--!=1)
  155. sb.append("{\"id\":\""+dept_id+"\",\"name\":\""+dept_name+"\",\"parentId\":\""+deptId+"\",\"open\":\"false\",\"isParent\":\"true\",\"icon\":\"/nwyj/scripts/qui/libs/icons/home.png\",\"orgLevel\":\"null\"},");
  156. }
  157. // if(sb.lastIndexOf(",")>-1){
  158. // sb.deleteCharAt(sb.lastIndexOf(","));
  159. // }
  160. } catch (ClassNotFoundException e) {
  161. // TODO Auto-generated catch block
  162. e.printStackTrace();
  163. } catch (SQLException e) {
  164. // TODO Auto-generated catch block
  165. e.printStackTrace();
  166. }finally{
  167. try {
  168. rs.close();
  169. pstm.close();
  170. conn.close();
  171. } catch (SQLException e) {
  172. // TODO Auto-generated catch block
  173. e.printStackTrace();
  174. }
  175. }
  176. // System.out.println("22222222222222222222222222"+sb.toString());
  177. return sb.toString();
  178. }
  179. public String getAllUnitShow3(String deptId,String butVal){//查询下级所有部门------(部门)
  180. String fdcode = getFdcodeByFddesc(butVal);
  181. String sql="select DEPT_ID,DEPT_NAME,PARENT_ID,DEPT_TYPE from SYS_DEPARTMENT where PARENT_ID='"+deptId+"' and DEPT_TYPE!='1' and CODES_ISSHOW like '%"+fdcode+"%' order by SORT";
  182. // String sql="select DEPT_ID,DEPT_NAME,PARENT_ID,DEPT_TYPE from SYS_DEPARTMENT where PARENT_ID='"+deptId+"' and DEPT_TYPE!='1' order by SORT";
  183. StringBuffer sb = new StringBuffer();
  184. DbConnection dbConn = new DbConnection();
  185. Connection conn = null;
  186. PreparedStatement pstm = null;
  187. ResultSet rs = null;
  188. int a=0;
  189. // sb.append("{\"id\":\"benbu\",\"name\":\"本部\",\"parentId\":\""+deptId+"\",\"open\":\"false\",\"isParent\":\"true\",\"icon\":\"/nwyj/scripts/qui/libs/icons/home.png\",\"orgLevel\":\"null\"},");
  190. try {
  191. conn = dbConn.getConnection();
  192. pstm = conn.prepareStatement(sql);
  193. // pstm.setString(1, butVal);
  194. rs = pstm.executeQuery();
  195. while(rs.next()){
  196. if(a==0){
  197. sb.append("{\"id\":\""+deptId+";1"+"\",\"name\":\"本部\",\"parentId\":\""+deptId+"\",\"open\":\"false\",\"isParent\":\"true\",\"icon\":\"/nwyj/scripts/qui/libs/icons/home.png\",\"orgLevel\":\"null\"},");
  198. a++;
  199. }
  200. String dept_id = rs.getString("DEPT_ID") == null ? "" : rs.getString("DEPT_ID");//单位ID
  201. String dept_name = rs.getString("DEPT_NAME") == null ? "" : rs.getString("DEPT_NAME");//单位NAME
  202. String parent_id = rs.getString("PARENT_ID") == null ? "" : rs.getString("PARENT_ID");//上级单位ID
  203. String dept_type = rs.getString("DEPT_TYPE") == null ? "" : rs.getString("DEPT_TYPE");//单位类型(单位--=1,部门--!=1)
  204. sb.append("{\"id\":\""+dept_id+"\",\"name\":\""+dept_name+"\",\"parentId\":\""+deptId+";1"+"\",\"open\":\"false\",\"isParent\":\"true\",\"icon\":\"/nwyj/scripts/qui/libs/icons/home.png\",\"orgLevel\":\"null\"},");
  205. }
  206. // if(sb.lastIndexOf(",")>-1){
  207. // sb.deleteCharAt(sb.lastIndexOf(","));
  208. // }
  209. } catch (ClassNotFoundException e) {
  210. // TODO Auto-generated catch block
  211. e.printStackTrace();
  212. } catch (SQLException e) {
  213. // TODO Auto-generated catch block
  214. e.printStackTrace();
  215. }finally{
  216. try {
  217. rs.close();
  218. pstm.close();
  219. conn.close();
  220. } catch (SQLException e) {
  221. // TODO Auto-generated catch block
  222. e.printStackTrace();
  223. }
  224. }
  225. // System.out.println("333333333333333333333"+sb.toString());
  226. return sb.toString();
  227. }
  228. public String getFdcodeByFddesc(String desc){
  229. String sql = "select fd_code from bm_mapvaluecanst where fd_description=? and fd_type='BM_SHOW_UNITES'";
  230. StringBuffer sb = new StringBuffer();
  231. DbConnection dbConn = new DbConnection();
  232. Connection conn = null;
  233. PreparedStatement pstm = null;
  234. ResultSet rs = null;
  235. try {
  236. conn = dbConn.getConnection();
  237. pstm = conn.prepareStatement(sql);
  238. pstm.setString(1, desc);
  239. rs = pstm.executeQuery();
  240. while(rs.next()){
  241. String fdCode = rs.getString("fd_code") == null ? "" : rs.getString("fd_code");
  242. sb.append(fdCode);
  243. }
  244. } catch (ClassNotFoundException e) {
  245. // TODO Auto-generated catch block
  246. e.printStackTrace();
  247. } catch (SQLException e) {
  248. // TODO Auto-generated catch block
  249. e.printStackTrace();
  250. }finally{
  251. try {
  252. rs.close();
  253. pstm.close();
  254. conn.close();
  255. } catch (SQLException e) {
  256. // TODO Auto-generated catch block
  257. e.printStackTrace();
  258. }
  259. }
  260. return sb.toString();
  261. }
  262. public String getAllShowUnitCode(){//获取常量表中所有fd_type='BM_SHOW_UNITES'的fd_code和fd_description
  263. String sql = "select fd_code,fd_description from bm_mapvaluecanst where fd_type='BM_SHOW_UNITES'";
  264. StringBuffer sb = new StringBuffer();
  265. DbConnection dbConn = new DbConnection();
  266. Connection conn = null;
  267. PreparedStatement pstm = null;
  268. ResultSet rs = null;
  269. try {
  270. conn = dbConn.getConnection();
  271. pstm = conn.prepareStatement(sql);
  272. rs = pstm.executeQuery();
  273. sb.append("\"allrows\":[");
  274. while(rs.next()){
  275. String fdCode = rs.getString("fd_code") == null ? "" : rs.getString("fd_code");
  276. String fdDesc = rs.getString("fd_description") == null ? "" : rs.getString("fd_description");
  277. sb.append("{\"name\":\""+fdDesc+"\",\"id\":\""+fdCode+"\"},");
  278. }
  279. if(sb.lastIndexOf(",")>-1){
  280. sb.deleteCharAt(sb.lastIndexOf(","));
  281. }
  282. sb.append("],");
  283. } catch (ClassNotFoundException e) {
  284. // TODO Auto-generated catch block
  285. e.printStackTrace();
  286. } catch (SQLException e) {
  287. // TODO Auto-generated catch block
  288. e.printStackTrace();
  289. }finally{
  290. try {
  291. rs.close();
  292. pstm.close();
  293. conn.close();
  294. } catch (SQLException e) {
  295. // TODO Auto-generated catch block
  296. e.printStackTrace();
  297. }
  298. }
  299. return sb.toString();
  300. }
  301. public String getCodeAndDesc(String code){//根据fd_code值从常量表中查询fd_description
  302. String sql = "select fd_code,fd_description from bm_mapvaluecanst where fd_code=?";
  303. StringBuffer sb = new StringBuffer();
  304. DbConnection dbConn = new DbConnection();
  305. Connection conn = null;
  306. PreparedStatement pstm = null;
  307. ResultSet rs = null;
  308. try {
  309. conn = dbConn.getConnection();
  310. pstm = conn.prepareStatement(sql);
  311. pstm.setString(1, code);
  312. rs = pstm.executeQuery();
  313. // sb.append("\"forShow\":[");
  314. while(rs.next()){
  315. String fdCode = rs.getString("fd_code") == null ? "" : rs.getString("fd_code");
  316. String fdDesc = rs.getString("fd_description") == null ? "" : rs.getString("fd_description");
  317. sb.append("{\"name\":\""+fdDesc+"\",\"id\":\""+fdCode+"\"},");
  318. }
  319. // if(sb.lastIndexOf(",")>-1){
  320. // sb.deleteCharAt(sb.lastIndexOf(","));
  321. // }
  322. // sb.append("]");
  323. } catch (ClassNotFoundException e) {
  324. // TODO Auto-generated catch block
  325. e.printStackTrace();
  326. } catch (SQLException e) {
  327. // TODO Auto-generated catch block
  328. e.printStackTrace();
  329. }finally{
  330. try {
  331. rs.close();
  332. pstm.close();
  333. conn.close();
  334. } catch (SQLException e) {
  335. // TODO Auto-generated catch block
  336. e.printStackTrace();
  337. }
  338. }
  339. return sb.toString();
  340. }
  341. public int updateCodes(String deptId,String codes){//从组织机构表SYS_DEPARTMENT中查询对应部门下的CODES_ISSHOW字段值
  342. String sql = "update SYS_DEPARTMENT set CODES_ISSHOW=? where DEPT_ID=?";
  343. StringBuffer sb = new StringBuffer();
  344. DbConnection dbConn = new DbConnection();
  345. Connection conn = null;
  346. PreparedStatement pstm = null;
  347. int n = 0;
  348. try {
  349. conn = dbConn.getConnection();
  350. pstm = conn.prepareStatement(sql);
  351. pstm.setString(1, codes);
  352. pstm.setString(2, deptId);
  353. n = pstm.executeUpdate();
  354. // while(rs.next()){
  355. // String codesIsShow = rs.getString("CODES_ISSHOW") == null ? "" : rs.getString("CODES_ISSHOW");
  356. // sb.append(codesIsShow);
  357. // }
  358. } catch (ClassNotFoundException e) {
  359. // TODO Auto-generated catch block
  360. e.printStackTrace();
  361. } catch (SQLException e) {
  362. // TODO Auto-generated catch block
  363. e.printStackTrace();
  364. }finally{
  365. try {
  366. // rs.close();
  367. pstm.close();
  368. conn.close();
  369. } catch (SQLException e) {
  370. // TODO Auto-generated catch block
  371. e.printStackTrace();
  372. }
  373. }
  374. return n;
  375. }
  376. public String getcodes(String deptId){//从组织机构表SYS_DEPARTMENT中查询对应部门下的CODES_ISSHOW字段值
  377. String sql = "select CODES_ISSHOW from SYS_DEPARTMENT where DEPT_ID=?";
  378. StringBuffer sb = new StringBuffer();
  379. DbConnection dbConn = new DbConnection();
  380. Connection conn = null;
  381. PreparedStatement pstm = null;
  382. ResultSet rs = null;
  383. try {
  384. conn = dbConn.getConnection();
  385. pstm = conn.prepareStatement(sql);
  386. pstm.setString(1, deptId);
  387. rs = pstm.executeQuery();
  388. while(rs.next()){
  389. String codesIsShow = rs.getString("CODES_ISSHOW") == null ? "" : rs.getString("CODES_ISSHOW");
  390. sb.append(codesIsShow);
  391. }
  392. } catch (ClassNotFoundException e) {
  393. // TODO Auto-generated catch block
  394. e.printStackTrace();
  395. } catch (SQLException e) {
  396. // TODO Auto-generated catch block
  397. e.printStackTrace();
  398. }finally{
  399. try {
  400. rs.close();
  401. pstm.close();
  402. conn.close();
  403. } catch (SQLException e) {
  404. // TODO Auto-generated catch block
  405. e.printStackTrace();
  406. }
  407. }
  408. return sb.toString();
  409. }
  410. public int getUnitTypeNum(){//获取常量表中fd_type='BM_SHOW_UNITES'记录的条数
  411. String sql = "select count(1) from bm_mapvaluecanst where fd_type='BM_SHOW_UNITES'";
  412. DbConnection dbConn = new DbConnection();
  413. Connection conn = null;
  414. PreparedStatement pstm = null;
  415. ResultSet rs = null;
  416. int n = 0;
  417. try {
  418. conn = dbConn.getConnection();
  419. pstm = conn.prepareStatement(sql);
  420. rs = pstm.executeQuery();
  421. while(rs.next()){
  422. n = rs.getInt("count(1)");
  423. }
  424. } catch (ClassNotFoundException e) {
  425. // TODO Auto-generated catch block
  426. e.printStackTrace();
  427. } catch (SQLException e) {
  428. // TODO Auto-generated catch block
  429. e.printStackTrace();
  430. }finally{
  431. try {
  432. rs.close();
  433. pstm.close();
  434. conn.close();
  435. } catch (SQLException e) {
  436. // TODO Auto-generated catch block
  437. e.printStackTrace();
  438. }
  439. }
  440. return n;
  441. }
  442. public int insertUnitTypes(String fdCode,String description,String fdType,int sortNum){//往常量表中新增记录
  443. String sql = "insert into bm_mapvaluecanst (FD_CODE,FD_DESCRIPTION,FD_TYPE,FD_SORT) values (?,?,?,?)";
  444. DbConnection dbConn = new DbConnection();
  445. Connection conn = null;
  446. PreparedStatement pstm = null;
  447. ResultSet rs = null;
  448. int n = 0;
  449. try {
  450. conn = dbConn.getConnection();
  451. pstm = conn.prepareStatement(sql);
  452. pstm.setString(1, fdCode);
  453. pstm.setString(2, description);
  454. pstm.setString(3, "BM_SHOW_UNITES");
  455. pstm.setInt(4, sortNum);
  456. n=pstm.executeUpdate();
  457. } catch (ClassNotFoundException e) {
  458. // TODO Auto-generated catch block
  459. e.printStackTrace();
  460. } catch (SQLException e) {
  461. // TODO Auto-generated catch block
  462. e.printStackTrace();
  463. }finally{
  464. try {
  465. if(rs!=null)
  466. rs.close();
  467. if(pstm!=null)
  468. pstm.close();
  469. if(conn!=null)
  470. conn.close();
  471. } catch (SQLException e) {
  472. // TODO Auto-generated catch block
  473. e.printStackTrace();
  474. }
  475. }
  476. return n;
  477. }
  478. }