将从数据库得到的信息分别以HTML,XML,Json的形式输出
package donghongyu.unit;import java.io.File;public class JdbcUtil {private static Connection conn;private JdbcUtil() {super();}public static synchronized Connection getConn() {if (conn == null) {try {// 加载驱动文件Class.forName("com.mysql.jdbc.Driver");// 创建属性文件对象File file = new File("F:/web/tomcate/webapps/test/WEB-INF/classes/jdbc.properties");// 将属性文件对象转化为流文件InputStream is = new FileInputStream(file);// 创建解读属性文件的属性的对象Properties prop = new Properties();// 将属性文件对象加载到属性对象的解析中prop.load(is);// 从属性文件取出对应的内容字段,并创建出相应的连接对象conn = DriverManager.getConnection(prop.getProperty("url"),prop.getProperty("user"), prop.getProperty("pass"));} catch (Exception e) {// TODO Auto-generated catch blocke.printStackTrace();}}// 返回数据库连接对象return conn;}//关闭资源,public static void release(Statement pstmt,ResultSet rs){if(rs!=null){try {rs.close();} catch (SQLException e) {// TODO Auto-generated catch blocke.printStackTrace();}}if(pstmt!=null){try {pstmt.close();} catch (SQLException e) {// TODO Auto-generated catch blocke.printStackTrace();}}}}