| | |
| | | package com.fgkj.services.ram; |
| | | |
| | | import java.sql.Connection; |
| | | |
| | | import com.fgkj.db.DBUtil; |
| | | import com.fgkj.dto.ServiceModel; |
| | | |
| | | public class DBUtilService { |
| | | |
| | | private ServiceModel model; |
| | | |
| | | public DBUtilService() { |
| | | model=new ServiceModel(); |
| | | } |
| | | |
| | | public ServiceModel getconn(){ |
| | | try { |
| | | Connection conn=DBUtil.getConn(); |
| | | if(conn!=null){ |
| | | DBUtil.close(null, null, conn); |
| | | model.setCode(1); |
| | | model.setMsg("查询成功!"); |
| | | }else{ |
| | | model.setCode(0); |
| | | model.setMsg("查询失败!"); |
| | | } |
| | | } catch (Exception e) { |
| | | // TODO Auto-generated catch block |
| | | model.setCode(0); |
| | | model.setMsg("查询失败!"); |
| | | e.printStackTrace(); |
| | | } |
| | | System.out.println(model); |
| | | return model; |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | DBUtilService dservice=new DBUtilService(); |
| | | dservice.getconn(); |
| | | } |
| | | } |
| | | // package com.fgkj.services.ram; |
| | | // |
| | | // import com.fgkj.db.DBUtil; |
| | | // import com.fgkj.dto.ServiceModel; |
| | | // |
| | | // import java.sql.Connection; |
| | | // |
| | | // public class DBUtilService { |
| | | // |
| | | // ServiceModel model = new ServiceModel(); |
| | | // |
| | | // public DBUtilService() { |
| | | // model=new ServiceModel(); |
| | | // } |
| | | // |
| | | // public ServiceModel getconn(){ |
| | | // try { |
| | | // Connection conn=DBUtil.getConn(); |
| | | // if(conn!=null){ |
| | | // DBUtil.close(null, null, conn); |
| | | // model.setCode(1); |
| | | // model.setMsg("查询成功!"); |
| | | // }else{ |
| | | // model.setCode(0); |
| | | // model.setMsg("查询失败!"); |
| | | // } |
| | | // } catch (Exception e) { |
| | | // // TODO Auto-generated catch block |
| | | // model.setCode(0); |
| | | // model.setMsg("查询失败!"); |
| | | // e.printStackTrace(); |
| | | // } |
| | | // System.out.println(model); |
| | | // } |
| | | // |
| | | // public static void main(String[] args) { |
| | | // DBUtilService dservice=new DBUtilService(); |
| | | // dservice.getconn(); |
| | | // } |
| | | // } |