private static final String XML_FILE_PROPERTY = \
private boolean autoShutdown = true;
public void contextInitialized(ServletContextEvent servletConfig) { String appDir = servletConfig.getServletContext().getRealPath(\ Properties properties = new Properties();
String value = servletConfig.getServletContext().getInitParameter( XML_FILE_PROPERTY);
LOG.debug(\ try {
File file = new File(value);
if (file.isAbsolute()) {
JAXPConfigurator.configure(value, false); } else {
LOG.debug(appDir + File.separator + value);
JAXPConfigurator.configure(appDir + File.separator + value, false); }
} catch (ProxoolException e) {
LOG.error(\ }
if (properties.size() > 0) {
try {
PropertyConfigurator.configure(properties); } catch (ProxoolException e) {
LOG.error(\ } } }
public void contextDestroyed(ServletContextEvent s) { if (autoShutdown) {
ProxoolFacade.shutdown(0); }
} }
====================================annotation生成表==============
package com.tcs.org.demostic.pub.until;
import org.hibernate.cfg.AnnotationConfiguration; import org.hibernate.cfg.Configuration;
import org.hibernate.tool.hbm2ddl.SchemaExport; /*
*功能:生成表
*先建mysql数据库(或)
*oracle实例 (demo)
*doc/oracle--mysql create.readme *
*/
@SuppressWarnings(\public class createTable {
public static void main(String[] args) {
Configuration cfg = new AnnotationConfiguration().configure(); SchemaExport export = new SchemaExport(cfg); export.create(true, true);
// SchemaUpdate update =new SchemaUpdate(cfg); // update.execute(true, true); } }
docBase=\debug=\