Easyconnectionpool2.0

  1. package com.mdj.dmdatabase.develop;
  2. import java.io.PrintWriter;
  3. import java.io.Serializable;
  4. import java.io.UnsupportedEncodingException;
  5. import java.sql.Connection;
  6. import java.sql.ResultSet;
  7. import java.sql.SQLException;
  8. import java.util.List;
  9. import java.util.Map;
  10. import java.util.Vector;
  11. import javax.sql.DataSource;
  12. /**
  13.  * @see Connectionpool EasyconnectionPool
  14.  * @author 武汉软件工程职业学院<br>
  15.  *         孟德军<br>
  16.  *         2009-01-01<br>
  17.  *         封装了Dbutils工具<br>
  18.  *         的部分细节
  19.  * @version 2.0
  20.  */
  21. public interface DmDataSource extends DataSource, Serializable {
  22.     /**
  23.      * @see #resultset 存放数据库的表信息.
  24.      */
  25.     ResultSet resultset = null;
  26.     /**
  27.      * @see #con 数据库连接
  28.      */
  29.     Connection con = null;
  30.     /**
  31.      * @see #pool 连接池容器.可自行选择。
  32.      */
  33.     Vector<Connection> pool = null;
  34.     /**
  35.      * @see #driverclass 数据库驱动类
  36.      */
  37.     String driverclass = null;
  38.     /**
  39.      * @see #uername 数据库用户名
  40.      */
  41.     String uername = null;
  42.     /**
  43.      * @see #password 数据库密码
  44.      */
  45.     String password = null;
  46.     /**
  47.      * @see #url 连接数据库url
  48.      */
  49.     String url = null;
  50.     /**
  51.      * @see #filepath 配置文件路径.
  52.      */
  53.     String filepath = null;
  54.     /**
  55.      * @see #logpath 日志文件路径.
  56.      */
  57.     String logpath = null;
  58.     /**
  59.      * @see #maxwaittime 允许等待时间
  60.      */
  61.     int maxwaittime = 0;
  62.     /**
  63.      * @see #delaytime 延迟时间
  64.      */
  65.     int delaytime = 0;
  66.     /**
  67.      * @see #maxconnection 最大连接
  68.      */
  69.     int maxconnection = 0;
  70.     /**
  71.      * @see #minconnection 最小连接
  72.      */
  73.     int minconnection = 0;
  74.     /**
  75.      * @see #poolsize 连接池大小.
  76.      */
  77.     int poolsize = 0;
  78.     public void closeConnectionPool() throws SQLException;
  79.     /**
  80.      * @param username 数据库用户名<br>password 数据库密码
  81.      * @deprecated 建议使用getconnection()
  82.      * @see #getConnection() 参见
  83.      */
  84.     public Connection getConnection(String username, String password)
  85.             throws SQLException;
  86.     /**
  87.      * @see #getConnection() 无用户名和密码,以在配置文件中配置。
  88.      */
  89.     public Connection getConnection() throws SQLException;
  90.     public PrintWriter getLogWriter() throws SQLException;
  91.     public int getLoginTimeout() throws SQLException;
  92.     public void releaseConnection(Connection con);
  93.     public void setLogWriter(PrintWriter out) throws SQLException;
  94.     public void setLoginTimeout(int seconds) throws SQLException;
  95.     public Map mapexecuteQuery(String sql) throws SQLException;
  96.     public List listexecuteQuery(String sql, Class beanclass)
  97.             throws SQLException;
  98.     public ResultSet getTables(String catalog, String schemapattern,
  99.             String tablenamepattern, String[] types) throws SQLException;
  100.     public int getJDBCMajorVersion() throws SQLException;
  101.     public int generalUpdate(String sql) throws SQLException;
  102.     public ResultSet generalQuery(String sql) throws SQLException;
  103.     public String toChinese(String str, String oldcharsetName,
  104.             String newcharsetName) throws UnsupportedEncodingException;
  105. }
  1. package com.mdj.dmdatabase.DmDriverManager;
  2. import java.io.File;
  3. import java.io.FileInputStream;
  4. import java.io.FileNotFoundException;
  5. import java.io.FileWriter;
  6. import java.io.IOException;
  7. import java.io.InputStream;
  8. import java.io.PrintWriter;
  9. import java.io.UnsupportedEncodingException;
  10. import java.sql.Connection;
  11. import java.sql.DatabaseMetaData;
  12. import java.sql.DriverManager;
  13. import java.sql.PreparedStatement;
  14. import java.sql.ResultSet;
  15. import java.sql.SQLException;
  16. import java.sql.Statement;
  17. import java.util.Date;
  18. import java.util.List;
  19. import java.util.Map;
  20. import java.util.Properties;
  21. import java.util.Timer;
  22. import java.util.TimerTask;
  23. import java.util.Vector;
  24. import javax.xml.parsers.DocumentBuilder;
  25. import javax.xml.parsers.DocumentBuilderFactory;
  26. import javax.xml.parsers.ParserConfigurationException;
  27. import org.apache.commons.dbutils.DbUtils;
  28. import org.apache.commons.dbutils.QueryRunner;
  29. import org.apache.commons.dbutils.handlers.BeanListHandler;
  30. import org.apache.commons.dbutils.handlers.MapListHandler;
  31. import org.w3c.dom.Document;
  32. import org.w3c.dom.Element;
  33. import org.w3c.dom.NodeList;
  34. import org.xml.sax.SAXException;
  35. import com.mdj.dmdatabase.pool.Dmconnection;
  36. /**
  37.  * @see Connectionpool EasyconnectionPool
  38.  * @author <hr><p bgcolor="#9acd32">武汉软件工程职业学院</p>
  39.  *         孟德军<br>
  40.  *         2009-01-03<br>
  41.  *         封装了Dbutils<br>
  42.  *         工具的部分细节
  43.  * 
  44.  * @version 2.0
  45.  */
  46. public class DatabaseManager extends Dmconnection {
  47.     /**
  48.      * 
  49.      */
  50.     private static final long serialVersionUID = 1L;
  51.     /**
  52.      * @see #databasemetaData 数据源.
  53.      */
  54.     private DatabaseMetaData databasemetaData;
  55.     /**
  56.      * @see #resultset 存放数据库的表信息.
  57.      */
  58.     private ResultSet resultset = null;
  59.     /**
  60.      * @see #map 存放mapexecuteQuery查询结果
  61.      */
  62.     private Map map = null;
  63.     /**
  64.      * @see #list 存放listexecuteQuery查询结果
  65.      */
  66.     private List list = null;
  67.     /**
  68.      * @see #con 数据库连接
  69.      */
  70.     private Connection con = null;
  71.     /**
  72.      * @see #pool 连接池容器.可自行选择。
  73.      */
  74.     private Vector<Connection> pool = null;
  75.     /**
  76.      * @see #driverclass 数据库驱动类
  77.      */
  78.     private String driverclass = "dm.jdbc.driver.DmDriver";
  79.     /**
  80.      * @see #uername 数据库用户名
  81.      */
  82.     private String username = "SYSDBA";
  83.     /**
  84.      * @see #password 数据库密码
  85.      */
  86.     private String password = "123456";
  87.     /**
  88.      * @see #url 连接数据库url
  89.      */
  90.     private String url = "jdbc:dm://localhost:12345/guest";
  91.     /**
  92.      * @see #filepath 配置文件路径.
  93.      */
  94.     private static String filepath = null;
  95.     /**
  96.      * @see #logpath 日志文件路径.
  97.      */
  98.     private String logpath = "..//server.log";
  99.     /**
  100.      * @see #maxwaittime 允许等待时间
  101.      */
  102.     private int maxwaittime = 10;
  103.     /**
  104.      * @see #delaytime 延迟时间
  105.      */
  106.     private int delaytime = 10;
  107.     /**
  108.      * @see #maxconnection 最大连接
  109.      */
  110.     private int maxconnection = 10;
  111.     /**
  112.      * @see #minconnection 最小连接
  113.      */
  114.     private int minconnection = 5;
  115.     /**
  116.      * @see #poolsize 连接池大小.
  117.      */
  118.     private int poolsize = 10;
  119.     /**
  120.      * @see #manager 本类实例.
  121.      */
  122.     private static DatabaseManager manager = null;
  123.     /**
  124.      * @see #timer 扫描连接池.
  125.      */
  126.     private Timer timer;
  127.     private PrintWriter writer;
  128.     private boolean loading = false;
  129.     /**
  130.      * @see #addConnection() 为连接池添加连接
  131.      * @throws ClassNotFoundException
  132.      */
  133.     private DatabaseManager() {
  134.         try {
  135.             init();
  136.             File file = new File(logpath);
  137.             writer = new PrintWriter(new FileWriter(file.getAbsolutePath(),
  138.                     true), true);
  139.             addConnection();
  140.         } catch (IOException e) {
  141.             e.printStackTrace();
  142.         }
  143.     }
  144.     private void init() {
  145.         if (loading == false) {
  146.             config(filepath);
  147.         } else {
  148.             readconfig(filepath);
  149.         }
  150.         pool = new Vector<Connection>(maxconnection);
  151.         timer = new Timer(true);
  152.     }
  153.     static public synchronized DatabaseManager getinstance(String path) {
  154.         // 必须先初始化变量filepath,然后在创建变量.
  155.         DatabaseManager.filepath = path;
  156.         if (manager == null) {
  157.             manager = new DatabaseManager();
  158.         }
  159.         return manager;
  160.     }
  161.     private void addConnection() {
  162.         serverlog("server start");
  163.         for (int i = 0; i < maxconnection; i++) {
  164.             try {
  165.                 Class.forName(driverclass);
  166.                 DriverManager.setLogWriter(writer);
  167.                 DriverManager.setLoginTimeout(maxwaittime);
  168.                 con = DriverManager.getConnection(url, username, password);
  169.                 pool.add(con);
  170.             } catch (ClassNotFoundException e) {
  171.                 // TODO Auto-generated catch block
  172.                 serverlog(e.getMessage());
  173.             } catch (SQLException e) {
  174.                 // TODO Auto-generated catch block
  175.                 serverlog(e.getMessage());
  176.             }
  177.         }
  178.     }
  179.     /**
  180.      * @see #releaseConnection(Connection) 释放连接,返还连接池.
  181.      * @return con 当前连接.
  182.      * 
  183.      */
  184.     public synchronized Connection getConnection() throws SQLException {
  185.         if (pool.size() > 0) {
  186.             con = pool.get(0);
  187.             pool.remove(0);
  188.             scaner();
  189.             return con;
  190.         } else {
  191.             return con;
  192.         }
  193.     }
  194.     /**
  195.      * @see #releaseConnection(Connection) 释放连接,返还连接池.
  196.      * @return con 当前连接.
  197.      * 
  198.      */
  199.     public synchronized Connection getConnection(String username,
  200.             String password) {
  201.         if (pool.size() > 0) {
  202.             con = pool.get(0);
  203.             pool.remove(0);
  204.             return con;
  205.         } else {
  206.             return con;
  207.         }
  208.     }
  209.     public synchronized void releaseConnection(Connection con) {
  210.         pool.add(con);
  211.     }
  212.     /**
  213.      * @return 无返回值
  214.      * @see #closeConnectionPool() 关闭连接,清空连接池.
  215.      * @throws SQLException
  216.      */
  217.     public void closeConnectionPool() throws SQLException {
  218.         for (int i = 0; i < pool.size(); i++) {
  219.             pool.get(i).close();
  220.             pool.clear();
  221.             timer.cancel();
  222.         }
  223.     }
  224.     /**
  225.      * @see #scaner()扫描连接池.
  226.      */
  227.     private void scaner() {
  228.         TimerTask task = new TimerTask() {
  229.             @Override
  230.             public void run() {
  231.                 // TODO Auto-generated method stub
  232.                 if (manager.pool.size() < maxconnection) {
  233.                     while (manager.pool.size() < maxconnection) {
  234.                         addConnection();
  235.                     }
  236.                 }
  237.             }
  238.         };
  239.         timer.schedule(task, 1000010000);
  240.     }
  241.     /**
  242.      * @see #config(String) 读取配置文件.<br>
  243.      *      初始化数据库连接数据.
  244.      * @since <hr>http://blog.csdn.net/mak0000 <a
  245.      *        href="http://blog.csdn.net/mak0000">更多信息</a>
  246.      * @throws path
  247.      *             为配置文件路径,文件路径错误会抛出FileNotFoundException异常
  248.      */
  249.     /**
  250.      * @see #config(String) 读取配置文件.
  251.      */
  252.     private void config(String path) {
  253.         loading = true;
  254.         DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
  255.         try {
  256.             DocumentBuilder builder = factory.newDocumentBuilder();
  257.             Document document = builder.parse(DatabaseManager.filepath);
  258.             NodeList nodelist = document.getElementsByTagName("dbmsdriver");
  259.             for (int i = 0; i < nodelist.getLength(); i++) {
  260.                 Element element = (Element) nodelist.item(i);
  261.                 driverclass = element.getElementsByTagName("driverclass").item(
  262.                         0).getFirstChild().getNodeValue();
  263.                 url = element.getElementsByTagName("url").item(0)
  264.                         .getFirstChild().getNodeValue();
  265.                 username = element.getElementsByTagName("username").item(0)
  266.                         .getFirstChild().getNodeValue();
  267.                 password = element.getElementsByTagName("password").item(0)
  268.                         .getFirstChild().getNodeValue();
  269.                 maxconnection = Integer
  270.                         .parseInt(element.getElementsByTagName("maxconnection")
  271.                                 .item(0).getFirstChild().getNodeValue());
  272.                 minconnection = Integer
  273.                         .parseInt(element.getElementsByTagName("minconnection")
  274.                                 .item(0).getFirstChild().getNodeValue());
  275.                 logpath = element.getElementsByTagName("logpath").item(0)
  276.                         .getFirstChild().getNodeValue();
  277.                 maxwaittime = Integer.parseInt(element.getElementsByTagName(
  278.                         "maxwaittime").item(0).getFirstChild().getNodeValue());
  279.                 delaytime = Integer.parseInt(element.getElementsByTagName(
  280.                         "delaytime").item(0).getFirstChild().getNodeValue());
  281.             }
  282.         } catch (ParserConfigurationException e) {
  283.             // TODO Auto-generated catch block
  284.             e.printStackTrace();
  285.             serverlog(new Date() + ":/t" + e.getMessage() + "/n");
  286.         } catch (SAXException e) {
  287.             e.printStackTrace();
  288.             serverlog(new Date() + ":/t" + e.getMessage() + "/n");
  289.         } catch (IOException e) {
  290.             e.printStackTrace();
  291.             serverlog(new Date() + ":/t" + e.getMessage() + "/n");
  292.         }
  293.     }
  294.     /**
  295.      * @deprecated 该方法为候选方法.
  296.      * @param path
  297.      *            配置文件路径.
  298.      */
  299.     public void readconfig(String path) {
  300.         loading = false;
  301.         Properties properties = new Properties();
  302.         try {
  303.             InputStream in = new FileInputStream(DatabaseManager.filepath);
  304.             properties.load(in);
  305.             driverclass = properties.getProperty("driverclass");
  306.             url = properties.getProperty("url");
  307.             username = properties.getProperty("username");
  308.             password = properties.getProperty("password");
  309.             maxconnection = Integer.parseInt(properties
  310.                     .getProperty("maxconnection"));
  311.             minconnection = Integer.parseInt(properties
  312.                     .getProperty("minconnection"));
  313.             delaytime = Integer.parseInt(properties.getProperty("delaytime"));
  314.             logpath = properties.getProperty("logpath");
  315.             in.close();
  316.         } catch (FileNotFoundException e) {
  317.             e.printStackTrace();
  318.         } catch (IOException e) {
  319.             e.printStackTrace();
  320.         }
  321.     }
  322.     /**
  323.      * @see #serverlog(String) 日志.
  324.      * @param msg
  325.      *            异常及日常信息.
  326.      * @since <a href="http://www.w3.org/xmlschema">建议将变量以配置文件形式存放,<br>
  327.      *        以方便使用,例如xml,properties<br>
  328.      *        文件.</a>
  329.      */
  330.     private void serverlog(String msg) {
  331.         writer.println(new Date() + ":" + msg);
  332.         writer.close();
  333.     }
  334.     /**
  335.      * @see #setLogWriter(PrintWriter) set delay time
  336.      * @throws SQLException
  337.      */
  338.     public void setLoginTimeout(int seconds) throws SQLException {
  339.         this.maxwaittime = seconds;
  340.     }
  341.     /**
  342.      * @see #getLoginTimeout() get delay time.
  343.      * @throws SQLException
  344.      */
  345.     public int getLoginTimeout() throws SQLException {
  346.         return maxwaittime;
  347.     }
  348.     /**
  349.      * @see #setLogWriter(PrintWriter) set logwriter.
  350.      * @throws SQLException
  351.      */
  352.     public void setLogWriter(PrintWriter out) throws SQLException {
  353.         this.writer = out;
  354.     }
  355.     /**
  356.      * @see #getLogWriter() get logwriter
  357.      * @throws SQLException
  358.      */
  359.     public PrintWriter getLogWriter() throws SQLException {
  360.         return writer;
  361.     }
  362.     /**
  363.      * @see #listexecuteQuery(String, Class) put the var in list,list includes objects bean
  364.      * @since Book.class<br>
  365.      *        Book book=(Book)result.get(i);<br>
  366.      *        book.getid();
  367.      */
  368.     @Override
  369.     public List listexecuteQuery(String sql, Class beanclass)
  370.             throws SQLException {
  371.         con = getConnection();
  372.         DbUtils.loadDriver(driverclass);
  373.         //build a queryrunner instance.
  374.         QueryRunner queryrunner = new QueryRunner();
  375.         list = (List) queryrunner.query(con, sql,
  376.                 new BeanListHandler(beanclass));
  377.         releaseConnection(con);
  378.         return list;
  379.     }
  380.     /**
  381.      * @see #mapexecuteQuery(String) map形式存放数据.list includes map
  382.      */
  383.     @Override
  384.     public Map mapexecuteQuery(String sql) throws SQLException {
  385.         // TODO Auto-generated method stub
  386.         con = getConnection();
  387.         DbUtils.loadDriver(driverclass);
  388.         QueryRunner queryrunner = new QueryRunner();
  389.         list = (List) queryrunner.query(con, sql, new MapListHandler());
  390.         releaseConnection(con);
  391.         for (int i = 0; i < list.size(); i++) {
  392.             map = (Map) list.get(i);
  393.         }
  394.         return map;
  395.     }
  396.     /**
  397.      * @see #getTables(String, String, String, String[])获取数据库表结构.
  398.      * @param catalog
  399.      *            ,schemaPattern,tableNamePattern,types
  400.      * 
  401.      */
  402.     public ResultSet getTables(String catalog, String schemaPattern,
  403.             String tableNamePattern, String[] types) throws SQLException {
  404.         con = getConnection();
  405.         databasemetaData = con.getMetaData();
  406.         resultset = databasemetaData.getTables(catalog, schemaPattern,
  407.                 tableNamePattern, types);
  408.         releaseConnection(con);
  409.         return resultset;
  410.     }
  411.     /**
  412.      * @see #getJDBCMajorVersion() jdbc主版本号.
  413.      */
  414.     @Override
  415.     public int getJDBCMajorVersion() throws SQLException {
  416.         // TODO Auto-generated method stub
  417.         con = getConnection();
  418.         databasemetaData = con.getMetaData();
  419.         int version = databasemetaData.getJDBCMajorVersion();
  420.         releaseConnection(con);
  421.         return version;
  422.     }
  423.     /**
  424.      * @see #getJDBCMinorVersion() jdbc次版本号.
  425.      */
  426.     @Override
  427.     public int getJDBCMinorVersion() throws SQLException {
  428.         // TODO Auto-generated method stub
  429.         con = getConnection();
  430.         databasemetaData = con.getMetaData();
  431.         int version = databasemetaData.getJDBCMinorVersion();
  432.         releaseConnection(con);
  433.         return version;
  434.     }
  435.     @Override
  436.     /*
  437.      * @see #getMaxConnections() 数据库支持的同时建立连接的对象数目.
  438.      */
  439.     public int getMaxConnections() throws SQLException {
  440.         con = getConnection();
  441.         databasemetaData = con.getMetaData();
  442.         int maxconnection = databasemetaData.getMaxConnections();
  443.         releaseConnection(con);
  444.         return maxconnection;
  445.     }
  446.     /**
  447.      * @see #getMaxStatements() 数据库支持同时打开statement的数目.
  448.      */
  449.     @Override
  450.     public int getMaxStatements() throws SQLException {
  451.         // TODO Auto-generated method stub
  452.         con = getConnection();
  453.         databasemetaData = con.getMetaData();
  454.         int minconnection = databasemetaData.getMaxStatements();
  455.         releaseConnection(con);
  456.         return minconnection;
  457.     }
  458.     /**
  459.      * @see #generalUpdate(String) 更新.
  460.      */
  461.     public int generalUpdate(String sql) {
  462.         int result = 0;
  463.         Statement statement;
  464.         try {
  465.             con = getConnection();
  466.             statement = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
  467.                     ResultSet.CONCUR_UPDATABLE);
  468.             result = statement.executeUpdate(sql);
  469.             statement.close();
  470.             releaseConnection(con);
  471.         } catch (SQLException e) {
  472.             // TODO Auto-generated catch block
  473.             serverlog(e.getSQLState() + "/t" + e.getMessage());
  474.         }
  475.         return result;
  476.     }
  477.     public ResultSet generalQuery(String sql) {
  478.         ResultSet result = null;
  479.         
  480.         Statement statement;
  481.         try {
  482.             con = getConnection();
  483.             statement = con.createStatement();
  484.             result = statement.executeQuery(sql);
  485.             result.close();
  486.             statement.close();
  487.             releaseConnection(con);
  488.         } catch (SQLException e) {
  489.             serverlog(e.getSQLState() + "/t" + e.getMessage());
  490.         }
  491.         return result;
  492.     }
  493.     public String toChinese(String str, String oldcharsetName,
  494.             String newcharsetName) {
  495.         String chinesestr = null;
  496.         if (str.equals(null) || str == "") {
  497.             chinesestr = "";
  498.         } else {
  499.             try {
  500.                 chinesestr = new String(str.getBytes(oldcharsetName),
  501.                         newcharsetName);
  502.             } catch (UnsupportedEncodingException e) {
  503.                 serverlog("/t" + e.getMessage());
  504.             }
  505.         }
  506.         return chinesestr;
  507.     }
  508. }

 

  1. package com.mdj.dmdatabase.test;
  2. import java.io.IOException;
  3. import java.sql.Connection;
  4. import java.sql.SQLException;
  5. import java.util.List;
  6. import java.util.Map;
  7. import com.mdj.dmdatabase.DmDriverManager.DatabaseManager;
  8. import com.mdj.dmdatabase.javabean.Guest;
  9. /**
  10.  * @since <a href="http://blog.csdn.net/mak0000">Connectionpool
  11.  *        EasyconnectionPool</a>
  12.  * @author 武汉软件工程职业学院<br>
  13.  *         孟德军<br>
  14.  *         2009-01-01<br>
  15.  *         封装了Dbutils工具<br>
  16.  *         的部分细节
  17.  * @version 2.0
  18.  * 
  19.  */
  20. public class Test {
  21.     /**
  22.      * @see #manager DatabaseManager类的实例.
  23.      */
  24.     private DatabaseManager manager;
  25.     /**
  26.      * @see #con <p bgcolor="#9acd32">java.sql.Connection con Connection实例</p>
  27.      */
  28.     private Connection con = null;
  29.     public Test(String path) throws IOException, SQLException {
  30.         
  31.     
  32.         manager = DatabaseManager.getinstance(path);
  33.         // con = manager.getConnection();
  34.         /**
  35.          * 此处书写代码. 查询数据无需用connection接收
  36.          */
  37.         /*int a=manager.generalUpdate("insert into guestbook(author,title,ip,updatetime,content) values('王红梅','你过得怎么样','192.168.18.1','2009-01-04','你过得怎么样')");
  38.         System.out.println(a);*/
  39.         Map map = manager.mapexecuteQuery("select * from guestbook");
  40.         for (int i = 0; i < map.size(); i++) {
  41.             System.out.println(map.get("author") + " " + map.get("title") + " "
  42.                     + map.get("ip") + map.get("updatetime") + " "
  43.                     + map.get("content"));
  44.         }
  45.         List list = manager.listexecuteQuery("select * from guestbook",
  46.                 Guest.class);
  47.         Guest guestbook = null;
  48.         for (int i = 0; i < list.size(); i++) {
  49.             guestbook = (Guest) list.get(i);
  50.             System.out
  51.                     .println(guestbook.getAuthor() + "/t"
  52.                             + guestbook.getTitle() + "/t" + guestbook.getIp()
  53.                             + "/t" + guestbook.getUpdatetime() + "/t"
  54.                             + guestbook.getContent());
  55.         }
  56.         
  57.         
  58.          manager.releaseConnection(con); manager.closeConnectionPool();
  59.          
  60.     }
  61.     
  62.     public static void main(String[] args) {
  63.         String path = System.getProperty("user.dir") + "//src//sysconfig.xml";
  64.         try {
  65.             new Test(path);
  66.         } catch (SQLException e) {
  67.         } catch (IOException e) {
  68.             e.printStackTrace();
  69.         }
  70.     }
  71. }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值