jdbc直接查询后台

阅读更多
          

// /**
// * 查询列表+总数-扩展
// *
// * @param
// * @return
// */
// public ListRange query_Testperson_ext(Map map) throws Exception {
// ListRange lr = new ListRange();
// try {
// //初始化驱动包 
//            Class.forName("oracle.jdbc.driver.OracleDriver"); 
//            //根据数据库连接字符,名称,密码给conn赋值 
//          Connection  conn=DriverManager.getConnection("jdbc:oracle:thin:@192.168.8.9:1521:ORCL", "OBSFRAME", "obsframeobsframe");  
//         try {
//         ArrayList list=new ArrayList();
//         String sql="select * from testperson where 1=1";
////         StringBuffer sql = new StringBuffer();
////         sql.append("select * from testperson where 1=1");
////         if(RHUtil.isNotEmpty(map.get("LIKExm"))){
////              sql.append(" and xm like'%"+map.get("LIKExm")+"%'");
////         }
////         if(RHUtil.isNotEmpty(map.get("LIKExb"))){
////              sql.append(" and xb like'%"+map.get("LIKExb")+"%'");
////         }
////         if(RHUtil.isNotEmpty(map.get("order"))){
////              sql.append(" and "+map.get("order")+"");
////         }
//          Statement   st = (Statement) conn.createStatement();    //创建用于执行静态sql语句的Statement对象,st属局部变量    
//                
//             ResultSet rs = st.executeQuery(sql);    //执行sql查询语句,返回查询数据的结果集   
//             int count=0;
//             while (rs.next()) { // 判断是否还有下一个数据    
//             String detailinfo = "";
//             String detailinfos = "";
//                 // 根据字段名获取相应的值    
//                 Clob clob = rs.getClob("bq");//Java.sql.Clob
//                 Blob blob = rs.getBlob("xxqk");//Java.sql.Clob
//                 list.add(rs.getString("uuid"));
//                 list.add(rs.getString("xm"));
//                 list.add(rs.getString("xb"));
//                 list.add(Long.parseLong(rs.getString("jf")));
//                 list.add(Long.parseLong(rs.getString("sjhm")));
//                 list.add(Long.parseLong(rs.getString("mz")));
//                 list.add(rs.getString("sfzh"));
//                 list.add(rs.getString("zrdw"));
//                 list.add(rs.getString("gkrq"));
//                 if(clob != null){
//                  detailinfo = clob.getSubString((long)1,(int)clob.length());
//                 }
//                 if(blob != null){
//                 count++;
//                  detailinfos = new String(blob.getBytes((long)1, (int)blob.length())); 
//                 }
//                 System.out.println("--------clob-----------"+detailinfo);
//                 System.out.println("--------blob-----------"+detailinfos);
//                 list.add(detailinfo);
//                 list.add(detailinfos);
//                 System.out.println("--------list-----------"+list.toString());
//             }
//             lr.setData(list.toArray());
//             lr.setTotalSize(count);
//             System.out.println("--------lr-----------"+lr.getData().toString());
//             conn.close();   //关闭数据库连接    
//                
//         } catch (SQLException e) {   
//             System.out.println("查询数据失败");   
//         }
// VpuseroplogBean bean = new VpuseroplogBean();
// bean.setOpcommand(GlobalOpt.LOG_QUERY_EXT);
// bean.setOpobject("测试人员");
// bean.setOptable("Testperson");
// bean.setOpcontent("查询列表总数扩展测试人员(Testperson)成功,操作对象信息:"+StringUtil.objToString(map));
// this.saveUserOpLog(bean,null);
// } catch (Exception e) {
// e.printStackTrace();
// log.error("TestpersonService异常query_Testperson_ext["+e+"]");
// }
// return lr;
// }

你可能感兴趣的:(jdbc)