|
|
//package com.ynxbd.wx.utils;
|
|
|
//
|
|
|
//import com.ynxbd.wx.config.datasource.DataBase;
|
|
|
//import org.apache.commons.beanutils.BeanUtils;
|
|
|
//import org.codehaus.jackson.map.ObjectMapper;
|
|
|
//
|
|
|
//import javax.servlet.ServletRequest;
|
|
|
//import javax.servlet.http.HttpServletResponse;
|
|
|
//import java.io.IOException;
|
|
|
//import java.io.PrintWriter;
|
|
|
//import java.io.UnsupportedEncodingException;
|
|
|
//import java.lang.reflect.InvocationTargetException;
|
|
|
//import java.nio.charset.StandardCharsets;
|
|
|
//import java.sql.*;
|
|
|
//import java.util.*;
|
|
|
//
|
|
|
//
|
|
|
//public class ObjMake {
|
|
|
//
|
|
|
// public ObjMake() {
|
|
|
//
|
|
|
// }
|
|
|
//
|
|
|
// public static Vector<Map<Object, Object>> popRs(int string, ResultSet rs) {
|
|
|
// Vector<Map<Object, Object>> vector = new Vector<>();
|
|
|
// try {
|
|
|
// Map<Object, Object> map;
|
|
|
// Object value;
|
|
|
// String fdname;
|
|
|
// ResultSetMetaData rmd = rs.getMetaData();
|
|
|
// int ColumnCount = rmd.getColumnCount();
|
|
|
// while (rs.next()) {
|
|
|
// map = new HashMap<>();
|
|
|
// for (int i = 1; i <= ColumnCount; i++) {
|
|
|
// if (string == 0)
|
|
|
// value = rs.getObject(i);
|
|
|
// else
|
|
|
// value = rs.getString(i);
|
|
|
// fdname = rmd.getColumnLabel(i).toLowerCase();
|
|
|
// map.put(fdname, value);
|
|
|
// }
|
|
|
// vector.add(map);
|
|
|
// }
|
|
|
// } catch (SQLException ex) {
|
|
|
// ex.printStackTrace();
|
|
|
// }
|
|
|
// return vector;
|
|
|
// }
|
|
|
//
|
|
|
// /**
|
|
|
// * @param obj - bean<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
// * @param rs - <EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݼ<EFBFBD>
|
|
|
// * @return Vector
|
|
|
// */
|
|
|
// public static Vector<Map<String, Object>> popRs(Object obj, ResultSet rs) {
|
|
|
// Map<String, Object> map = new HashMap<>();
|
|
|
// Vector<Map<String, Object>> vector = new Vector<>();
|
|
|
// Object value = null;
|
|
|
// Object bean = null;
|
|
|
//
|
|
|
// if (obj != null) {
|
|
|
// Class<?> clazz = obj.getClass();
|
|
|
// try {
|
|
|
// ResultSetMetaData rmd = rs.getMetaData();
|
|
|
// while (rs.next()) {
|
|
|
// try {
|
|
|
// bean = clazz.newInstance();
|
|
|
// } catch (IllegalAccessException | InstantiationException ex1) {
|
|
|
// ex1.printStackTrace();
|
|
|
// }
|
|
|
//
|
|
|
// for (int i = 1; i <= rmd.getColumnCount(); i++) {
|
|
|
// String fdname = rmd.getColumnLabel(i).toLowerCase();
|
|
|
// // System.out.println(fdname);
|
|
|
// String fdtype = rmd.getColumnTypeName(i);
|
|
|
// if (fdtype.indexOf("(") > 0)
|
|
|
// fdtype = fdtype.substring(0, fdtype.indexOf("("));
|
|
|
// if (fdtype.toUpperCase().contains("CHAR") || fdtype.toUpperCase().equals("LONG") || "DECIMAL".equals(fdtype))
|
|
|
// // value = iso2gb(rs.getString(fdname));
|
|
|
// // //<EFBFBD>ַ<EFBFBD>仯windows
|
|
|
// value = rs.getString(fdname); // <EFBFBD>ַ<EFBFBD>仯linux
|
|
|
// else if (fdtype.equals("DATE") || fdtype.equals("DATETIME")) {
|
|
|
// try {
|
|
|
// value = rs.getTimestamp(fdname);
|
|
|
// String s = value.toString();
|
|
|
// if (s.indexOf(".0") > 0) {
|
|
|
// value = s.substring(0, s.indexOf(".0"));
|
|
|
// }
|
|
|
// } catch (Exception e) {
|
|
|
// e.printStackTrace();
|
|
|
// }
|
|
|
// } else if (fdtype.equals("NUMBER") || fdtype.equals("DOUBLE")) {
|
|
|
// if (rmd.getScale(i) == 0)
|
|
|
// value = rs.getInt(fdname);
|
|
|
// else
|
|
|
// value = String.valueOf(rs.getDouble(fdname));
|
|
|
// } else if (fdtype.toUpperCase().contains("INT")) {
|
|
|
// if ("BIGINT".equals(fdtype.toUpperCase())) {
|
|
|
// value = rs.getLong(fdname);
|
|
|
// } else {
|
|
|
// value = rs.getInt(fdname);
|
|
|
// }
|
|
|
// } else if (fdtype.equals("FLOAT")) {
|
|
|
// value = String.valueOf(rs.getFloat(fdname));
|
|
|
// }
|
|
|
//
|
|
|
// if (value != null)
|
|
|
// map.put(fdname, value);
|
|
|
// value = null;
|
|
|
// }
|
|
|
// try {
|
|
|
//
|
|
|
// BeanUtils.populate(bean, map);
|
|
|
// vector.add(map);
|
|
|
// map.clear();
|
|
|
// } catch (InvocationTargetException | IllegalAccessException ex) {
|
|
|
// ex.printStackTrace();
|
|
|
// }
|
|
|
// }
|
|
|
// } catch (SQLException ex) {
|
|
|
// ex.printStackTrace();
|
|
|
// }
|
|
|
//
|
|
|
// } else {
|
|
|
// try {
|
|
|
// ResultSetMetaData rmd = rs.getMetaData();
|
|
|
// while (rs.next()) {
|
|
|
// map = new HashMap<>();
|
|
|
// for (int i = 1; i <= rmd.getColumnCount(); i++) {
|
|
|
// String fdname = rmd.getColumnLabel(i).toLowerCase();
|
|
|
// // System.out.println(fdname);
|
|
|
// String fdtype = rmd.getColumnTypeName(i);
|
|
|
// if (fdtype.indexOf("(") > 0)
|
|
|
// fdtype = fdtype.substring(0, fdtype.indexOf("("));
|
|
|
// if (fdtype.toUpperCase().contains("CHAR") || fdtype.toUpperCase().equals("LONG"))
|
|
|
// // value = iso2gb(rs.getString(fdname));
|
|
|
// // //<EFBFBD>ַ<EFBFBD>仯windows
|
|
|
// value = rs.getString(fdname); // <EFBFBD>ַ<EFBFBD>仯linux
|
|
|
// else if (fdtype.equals("DATE") || fdtype.equals("DATETIME")) {
|
|
|
// try {
|
|
|
// value = rs.getTimestamp(fdname);
|
|
|
// String s = value.toString();
|
|
|
// if (s.indexOf(".0") > 0) {
|
|
|
// value = s.substring(0, s.indexOf(".0"));
|
|
|
// }
|
|
|
// } catch (Exception e) {
|
|
|
// e.printStackTrace();
|
|
|
// }
|
|
|
// } else if (fdtype.equals("NUMBER") || fdtype.equals("DOUBLE")) {
|
|
|
// if (rmd.getScale(i) == 0)
|
|
|
// value = rs.getInt(fdname);
|
|
|
// else
|
|
|
// value = String.valueOf(rs.getDouble(fdname));
|
|
|
// } else if (fdtype.toUpperCase().contains("INT")) {
|
|
|
// if ("BIGINT".equals(fdtype.toUpperCase())) {
|
|
|
// value = rs.getLong(fdname);
|
|
|
// } else {
|
|
|
// value = rs.getInt(fdname);
|
|
|
// }
|
|
|
//
|
|
|
// } else if (fdtype.equals("FLOAT")) {
|
|
|
// value = String.valueOf(rs.getFloat(fdname));
|
|
|
// }
|
|
|
//
|
|
|
// if (value != null)
|
|
|
// // System.out.println(fdname + " : " +value);
|
|
|
// map.put(fdname, value);
|
|
|
// value = null;
|
|
|
// }
|
|
|
//
|
|
|
// vector.add(map);
|
|
|
//
|
|
|
// }
|
|
|
// } catch (SQLException ex) {
|
|
|
// ex.printStackTrace();
|
|
|
// }
|
|
|
// }
|
|
|
//
|
|
|
// return vector;
|
|
|
// }
|
|
|
//
|
|
|
// /**
|
|
|
// * <EFBFBD><EFBFBD>ý<EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Լ<EFBFBD><EFBFBD>е<EFBFBD><EFBFBD><EFBFBD>ƺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
// *
|
|
|
// * @param obj -
|
|
|
// * <EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD>bean
|
|
|
// * @param rs -
|
|
|
// * <EFBFBD><EFBFBD>ݼ<EFBFBD>
|
|
|
// */
|
|
|
// public static void popRsSingle(Object obj, ResultSet rs) {
|
|
|
// Map<String, Object> map = new HashMap<>();
|
|
|
// Object value = null;
|
|
|
// try {
|
|
|
//
|
|
|
// ResultSetMetaData rmd = rs.getMetaData();// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
// for (int i = 1; i <= rmd.getColumnCount(); i++) {
|
|
|
// String fdName = rmd.getColumnName(i).toLowerCase();// <EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><EFBFBD>ΪСд
|
|
|
// String fdType = rmd.getColumnTypeName(i);// <EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
// if (fdType.indexOf("(") > 0)
|
|
|
// fdType = fdType.substring(0, fdType.indexOf("("));
|
|
|
//
|
|
|
// if (fdType.toUpperCase().contains("CHAR")) // <EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><EFBFBD><EFBFBD>ɴ<EFBFBD>д
|
|
|
// // <EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD>CHAR<EFBFBD><EFBFBD>ͬ
|
|
|
// // value = iso2gb(rs.getString(fdname)); //<EFBFBD>ַ<EFBFBD>仯windows
|
|
|
// value = rs.getString(fdName); // <EFBFBD>ַ<EFBFBD>仯linux
|
|
|
// else if (fdType.equals("DATE") || fdType.equals("DATETIME")) {// <EFBFBD><EFBFBD><EFBFBD>ڸ<EFBFBD>ʽ
|
|
|
// try {
|
|
|
// value = rs.getTimestamp(fdName).toString();
|
|
|
//
|
|
|
// String s = value.toString();
|
|
|
// if (s.indexOf(".0") > 0) {
|
|
|
// value = s.substring(0, s.indexOf(".0"));
|
|
|
// }
|
|
|
// } catch (Exception e) {
|
|
|
// e.printStackTrace();
|
|
|
// }
|
|
|
// } else if (fdType.equals("NUMBER") || fdType.equals("DOUBLE")) {
|
|
|
// if (rmd.getScale(i) == 0) // <EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȩ<EFBFBD><EFBFBD>
|
|
|
// value = rs.getInt(fdName);
|
|
|
// else
|
|
|
// value = String.valueOf(rs.getDouble(fdName));// Double-><EFBFBD><EFBFBD><EFBFBD><EFBFBD>->String
|
|
|
// } else if (fdType.toUpperCase().contains("INT")) {
|
|
|
// value = rs.getInt(fdName);
|
|
|
// }
|
|
|
//
|
|
|
// if (value != null) {
|
|
|
// map.put(fdName, value);
|
|
|
// }
|
|
|
// value = null;
|
|
|
// }
|
|
|
// BeanUtils.populate(obj, map);
|
|
|
//
|
|
|
// } catch (Exception e) {
|
|
|
// e.printStackTrace();
|
|
|
// }
|
|
|
// }
|
|
|
//
|
|
|
// /**
|
|
|
// * <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD>bean<EFBFBD><EFBFBD>
|
|
|
// *
|
|
|
// * @param obj -
|
|
|
// * <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD>bean
|
|
|
// * @param request -
|
|
|
// * <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
// */
|
|
|
// public static void pop(Object obj, ServletRequest request) {
|
|
|
//
|
|
|
// Map<String, Object> map = new HashMap<>();
|
|
|
// String name;
|
|
|
// String value;
|
|
|
//
|
|
|
// Enumeration<String> parameterNames = request.getParameterNames();
|
|
|
// while (parameterNames.hasMoreElements()) {
|
|
|
// name = parameterNames.nextElement();
|
|
|
// value = request.getParameter(name);
|
|
|
//
|
|
|
// if (value != null) {
|
|
|
// map.put(name, value);
|
|
|
// }
|
|
|
// }
|
|
|
//
|
|
|
// try {
|
|
|
// BeanUtils.populate(obj, map);
|
|
|
//
|
|
|
// } catch (InvocationTargetException | IllegalAccessException ex) {
|
|
|
// ex.printStackTrace();
|
|
|
// }
|
|
|
// }
|
|
|
//
|
|
|
// /**
|
|
|
// * <EFBFBD><EFBFBD>map<EFBFBD>е<EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD>bean<EFBFBD><EFBFBD>
|
|
|
// *
|
|
|
// * @param obj Object <EFBFBD><EFBFBD><EFBFBD>bean
|
|
|
// * @param map HashMap <EFBFBD><EFBFBD><EFBFBD>
|
|
|
// */
|
|
|
// public static void pop(Object obj, HashMap<String, Object> map) {
|
|
|
// try {
|
|
|
// BeanUtils.populate(obj, map);
|
|
|
// } catch (InvocationTargetException | IllegalAccessException ex) {
|
|
|
// ex.printStackTrace();
|
|
|
// }
|
|
|
// }
|
|
|
//
|
|
|
// /**
|
|
|
// * @param s
|
|
|
// * @return String
|
|
|
// */
|
|
|
// public static String message(String s) {
|
|
|
// String returnVal = "";
|
|
|
// returnVal = returnVal + "<html>";
|
|
|
// returnVal = returnVal + "<head><title>Servlet1</title></head>";
|
|
|
// returnVal = returnVal + "<body bgcolor=\"#ffffff\">";
|
|
|
// returnVal = returnVal + "<script language=\"javascript\">";
|
|
|
// returnVal = returnVal + s;
|
|
|
// returnVal = returnVal + "</script>";
|
|
|
// returnVal = returnVal + "</body></html>";
|
|
|
// return returnVal;
|
|
|
// }
|
|
|
//
|
|
|
// /**
|
|
|
// * @param response
|
|
|
// * @param s
|
|
|
// */
|
|
|
// public static void sendMessage(HttpServletResponse response, String s) {
|
|
|
// response.setContentType("text/html; charset=UTF-8");
|
|
|
// try {
|
|
|
// PrintWriter out = response.getWriter();
|
|
|
// out.println(message("alert(\"" + s + "\");"));
|
|
|
// } catch (IOException ex) {
|
|
|
// ex.printStackTrace();
|
|
|
// }
|
|
|
// }
|
|
|
//
|
|
|
// public static java.sql.Date getCurrentDate() {
|
|
|
// java.util.Date d = new java.util.Date();
|
|
|
// return new java.sql.Date(d.getYear(), d.getMonth(), d.getDate());
|
|
|
// }
|
|
|
//
|
|
|
// public static java.sql.Date getCurrentDateTime() {
|
|
|
// java.util.Date d = new java.util.Date();
|
|
|
// return new java.sql.Date(d.getTime());
|
|
|
// }
|
|
|
//
|
|
|
// /**
|
|
|
// * <EFBFBD><EFBFBD>ݵõ<EFBFBD><EFBFBD><EFBFBD>id<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD>Ķ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
// *
|
|
|
// * @param clsName
|
|
|
// * @param request
|
|
|
// * @return
|
|
|
// */
|
|
|
// public static Object pop(String clsName, ServletRequest request) {
|
|
|
// try {
|
|
|
// Class cls = Class.forName(clsName);
|
|
|
// Object o = cls.newInstance();
|
|
|
// pop(o, request);
|
|
|
// return o;
|
|
|
// } catch (Exception e) {
|
|
|
// e.printStackTrace();
|
|
|
// }
|
|
|
// return null;
|
|
|
// }
|
|
|
//
|
|
|
// public static Vector<Map<String, Object>> popRs(String clsName, ResultSet rs) {
|
|
|
// try {
|
|
|
// if ("Object".equals(clsName)) {
|
|
|
// return popRs("0", rs);
|
|
|
// } else if ("String".equals(clsName)) {
|
|
|
// return popRs("1", rs);
|
|
|
// } else {
|
|
|
// Object o = null;
|
|
|
// if (clsName != null) {
|
|
|
// Class cls = Class.forName(clsName);
|
|
|
// o = cls.newInstance();
|
|
|
// }
|
|
|
// return popRs(o, rs);
|
|
|
// }
|
|
|
// } catch (Exception e) {
|
|
|
// e.printStackTrace();
|
|
|
// }
|
|
|
// return new Vector<>();
|
|
|
// }
|
|
|
//
|
|
|
// /**
|
|
|
// * @param clsName
|
|
|
// * @param rs
|
|
|
// * @return
|
|
|
// */
|
|
|
// public static Object popRsSingle(String clsName, ResultSet rs) {
|
|
|
// try {
|
|
|
// Object o = Class.forName(clsName).newInstance();
|
|
|
// popRsSingle(o, rs);
|
|
|
// return o;
|
|
|
// } catch (Exception e) {
|
|
|
// e.printStackTrace();
|
|
|
// }
|
|
|
// return null;
|
|
|
// }
|
|
|
//
|
|
|
// public static Vector<Map<String, Object>> popRsBySql(String sql, String clsName, Connection con) {
|
|
|
// try {
|
|
|
// if (con.isClosed()) {
|
|
|
// con = DataBase.getConnection();
|
|
|
// }
|
|
|
// Statement stmt = con.createStatement();
|
|
|
// ResultSet rs = stmt.executeQuery(sql);
|
|
|
//
|
|
|
// Vector<Map<String, Object>> v = popRs(clsName, rs);
|
|
|
// rs.close();
|
|
|
// stmt.close();
|
|
|
//
|
|
|
// return v;
|
|
|
// } catch (SQLException e) {
|
|
|
// e.printStackTrace();
|
|
|
// } finally {
|
|
|
// DataBase.close(con);
|
|
|
// }
|
|
|
// return new Vector<>();
|
|
|
// }
|
|
|
//
|
|
|
// public static String JsonRsBySql(String sql, Connection con) {
|
|
|
// try {
|
|
|
// if (con.isClosed()) {
|
|
|
// con = DataBase.getConnection();
|
|
|
// }
|
|
|
// Statement stmt = con.createStatement();
|
|
|
// ResultSet rs = stmt.executeQuery(sql);
|
|
|
// List<Map<String, Object>> list = popRs(null, rs);
|
|
|
// rs.close();
|
|
|
// stmt.close();
|
|
|
// ObjectMapper mapper = new ObjectMapper();
|
|
|
//
|
|
|
// return mapper.writeValueAsString(convertSelect2(list));
|
|
|
// } catch (IOException | SQLException e) {
|
|
|
// e.printStackTrace();
|
|
|
// } finally {
|
|
|
// DataBase.close(con);
|
|
|
// }
|
|
|
// return "[]";
|
|
|
// }
|
|
|
//
|
|
|
// public static List<Object> convertSelect2(List<Map<String, Object>> rs) {
|
|
|
// List<Object> l = new ArrayList<>();
|
|
|
//
|
|
|
// Object content;
|
|
|
// Object id;
|
|
|
// Map<String, String> m;
|
|
|
// int i = 0;
|
|
|
// for (Map<String, Object> map : rs) {
|
|
|
// m = new HashMap<>();
|
|
|
// content = map.get("content");
|
|
|
// id = map.get("id");
|
|
|
// if (content == null) {
|
|
|
// m.put("text", "");
|
|
|
// } else {
|
|
|
// m.put("text", content.toString());
|
|
|
// }
|
|
|
// if (id == null) {
|
|
|
// m.put("id", String.valueOf(i));
|
|
|
// } else {
|
|
|
// m.put("id", id.toString());
|
|
|
// }
|
|
|
//
|
|
|
// i++;
|
|
|
// l.add(m);
|
|
|
// }
|
|
|
// return l;
|
|
|
// }
|
|
|
//
|
|
|
// public static Vector<Map<String, Object>> popRsBySql_old(String sql, String clsName, Connection con) {
|
|
|
// try {
|
|
|
// if (con.isClosed()) {
|
|
|
// con = DataBase.getConnection();
|
|
|
// }
|
|
|
// Statement stmt = con.createStatement();
|
|
|
// ResultSet rs = stmt.executeQuery(sql);
|
|
|
//
|
|
|
// Vector<Map<String, Object>> v = popRs(clsName, rs);
|
|
|
// rs.close();
|
|
|
// stmt.close();
|
|
|
//
|
|
|
// return v;
|
|
|
// } catch (SQLException e) {
|
|
|
// System.out.println(e.getMessage());
|
|
|
// }
|
|
|
// return new Vector<>();
|
|
|
// }
|
|
|
//
|
|
|
// public static String executeSql1(String strSql, Connection con) throws SQLException {
|
|
|
//
|
|
|
// con.setAutoCommit(false);
|
|
|
// Statement m_statement = con.createStatement();
|
|
|
// String state = "";
|
|
|
// state = String.valueOf(m_statement.executeUpdate(strSql));
|
|
|
// con.commit();
|
|
|
// m_statement.close();
|
|
|
// con.setAutoCommit(true);
|
|
|
// return state;
|
|
|
//
|
|
|
// }
|
|
|
//
|
|
|
// public static String executeSql(String strSql, Connection con) {
|
|
|
// try {
|
|
|
// if (con.isClosed()) {
|
|
|
// con = DataBase.getConnection();
|
|
|
// }
|
|
|
// con.setAutoCommit(false);
|
|
|
// Statement m_statement = con.createStatement();
|
|
|
// String state = "";
|
|
|
// // System.out.print(strSql);
|
|
|
// state = String.valueOf(m_statement.executeUpdate(strSql));
|
|
|
// con.commit();
|
|
|
// m_statement.close();
|
|
|
// con.setAutoCommit(true);
|
|
|
//
|
|
|
// return state;
|
|
|
// } catch (SQLException e) {
|
|
|
// try {
|
|
|
// con.rollback();
|
|
|
// } catch (SQLException ex) {
|
|
|
// return e.toString() + "\t" + ex.toString();
|
|
|
// }
|
|
|
// return e.toString();
|
|
|
// } finally {
|
|
|
// DataBase.close(con);
|
|
|
// }
|
|
|
// }
|
|
|
//
|
|
|
//
|
|
|
// public static String executeSql_old(String strSql, Connection con) {
|
|
|
// try {
|
|
|
// if (con.isClosed()) {
|
|
|
// con = DataBase.getConnection();
|
|
|
// }
|
|
|
// con.setAutoCommit(false);
|
|
|
// Statement m_statement = con.createStatement();
|
|
|
// String state = "";
|
|
|
// state = String.valueOf(m_statement.executeUpdate(strSql));
|
|
|
// con.commit();
|
|
|
// m_statement.close();
|
|
|
// con.setAutoCommit(true);
|
|
|
//
|
|
|
// return state;
|
|
|
// } catch (SQLException e) {
|
|
|
// try {
|
|
|
// con.rollback();
|
|
|
//
|
|
|
// } catch (SQLException ex) {
|
|
|
// return e.toString() + "\t" + ex.toString();
|
|
|
// }
|
|
|
// return e.toString();
|
|
|
// }
|
|
|
// }
|
|
|
//
|
|
|
// /**
|
|
|
// * <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>⣬ISOתΪUTF-8<EFBFBD><EFBFBD><EFBFBD>룬<EFBFBD><EFBFBD><EFBFBD><EFBFBD>POST<EFBFBD><EFBFBD>GET<EFBFBD><EFBFBD>ʽȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
// *
|
|
|
// * @param str ԭʼ<EFBFBD>ı<EFBFBD>
|
|
|
// * @return ת<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD>
|
|
|
// */
|
|
|
// public static String iso2gb(String str) {
|
|
|
// if (str != null) {
|
|
|
// byte[] tem = null;
|
|
|
// try {
|
|
|
// tem = str.getBytes("ISO8859_1");
|
|
|
// } catch (UnsupportedEncodingException e) {
|
|
|
// System.out.println("Error: Method: dbconn.iso2gb :" + e.getMessage());
|
|
|
// }
|
|
|
// if (tem != null) {
|
|
|
// str = new String(tem, StandardCharsets.UTF_8);
|
|
|
// }
|
|
|
// }
|
|
|
// return str;
|
|
|
// }
|
|
|
//
|
|
|
// // =====================================================================
|
|
|
//
|
|
|
// /**
|
|
|
// * <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>⣬UTF-8תISO<EFBFBD><EFBFBD><EFBFBD>룬<EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><EFBFBD>д<EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><EFBFBD>
|
|
|
// *
|
|
|
// * @param str ԭʼ<EFBFBD>ı<EFBFBD>
|
|
|
// * @return ת<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD>
|
|
|
// */
|
|
|
// public static String gb2iso(String str) {
|
|
|
// if (str != null) {
|
|
|
// byte[] tep = null;
|
|
|
// tep = str.getBytes(StandardCharsets.UTF_8);
|
|
|
// try {
|
|
|
// str = new String(tep, "ISO8859_1");
|
|
|
// } catch (UnsupportedEncodingException e) {
|
|
|
// System.out.println("Error: Method: dbconn.gb2iso :" + e.getMessage());
|
|
|
// }
|
|
|
// }
|
|
|
// return str;
|
|
|
// }
|
|
|
//
|
|
|
//}
|
|
|
|