j+a+v+a

 
 

常用链接

  • 我的随笔
  • 我的评论
  • 我的参与

留言簿(1)

  • 给我留言
  • 查看公开留言
  • 查看私人留言

随笔档案

  • 2007年7月 (4)

搜索

  •  

最新评论

阅读排行榜

  • 1. StringtoDate的方法(949)
  • 2. resin+xml和tomcat+xml配置(712)
  • 3. 启动服务读取XML配置文件(解析XML)(420)
  • 4. 定时统计(274)

评论排行榜

  • 1. resin+xml和tomcat+xml配置(0)
  • 2. StringtoDate的方法(0)
  • 3. 定时统计(0)
  • 4. 启动服务读取XML配置文件(解析XML)(0)

Powered by: 博客园
模板提供:沪江博客
BlogJava | 首页 | 发新随笔 | 发新文章 | 联系 | 聚合 | 管理

2007年7月24日

resin+xml和tomcat+xml配置

reisn+xml
conf\resin.conf
timesten数据库:

 1 <database>
 2            <jndi-name>qipai</jndi-name>
 3            <driver type="com.timesten.jdbc.TimesTenClientDriver">
 4              <url>jdbc:timesten:client:qipai</url>
 5              <user></user>
 6              <password></password>
 7             </driver>
 8             <max-active-time>100</max-active-time>
 9             <max-idle-time>30s</max-idle-time>
10      <transaction-timeout>1000</transaction-timeout>
11      <max-connections>100</max-connections>
12  </database>


oracle数据库:

 1 <database>
 2            <jndi-name>qipainw</jndi-name>
 3            <driver type="oracle.jdbc.driver.OracleDriver">
 4              <url>jdbc:oracle:thin:@192.168.*.*:6688:tang</url>
 5              <user>game_qipai</user>
 6              <password>qipai</password>
 7             </driver>
 8             <max-active-time>100</max-active-time>
 9             <max-idle-time>30s</max-idle-time>
10         <transaction-timeout>1000</transaction-timeout>
11         <max-connections>100</max-connections>
12          </database>

 

1 <web-app id="/YourwebName" document-directory="D:\YourwebName">
2               <system-property javax.xml.transform.TransformerFactory="org.apache.xalan.processor.TransformerFactoryImpl"/>
3         <system-property javax.xml.parsers.DocumentBuilderFactory="org.apache.xerces.jaxp.DocumentBuilderFactoryImpl"/>
4         <system-property javax.xml.parsers.SAXParserFactory="org.apache.xerces.jaxp.SAXParserFactoryImpl"/>
5         <system-property org.xml.sax.driver="org.apache.xerces.parsers.SAXParser"/>
6       </web-app>



applicationContext-resources.xml

1 <bean id="qipainwDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
2         <property name="jndiName"><value>java:comp/env/qipainw</value></property>
3     </bean>
4 
5     
6     <bean id="qipaiDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
7         <property name="jndiName"><value>java:comp/env/qipai</value></property>
8     </bean>

 

tomcat+xml
 conf\server.xml

1  <Connector 
2 port="8080"    maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
3                enableLookups="false" redirectPort="8443" acceptCount="100"
4                debug="0" connectionTimeout="20000" 
5                disableUploadTimeout="true" 
6                useBodyEncodingForURI="true" />
1 <Context path="/YourwebName" reloadable="false" 
2               docBase="D:\YourwebName" 
3               workDir="D:\YourwebName\work" /> 

applicationContext-resources.xml
 1  <bean id="qipainwDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
 2         <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/>
 3         <property name="url" value="jdbc:oracle:thin:@192.168.*.*:6688:tang"/>
 4         <property name="username" value="game_qipai"/>
 5         <property name="password" value="qipai"/>
 6         <property name="maxActive" value="100"/>
 7         <property name="maxIdle" value="30"/>
 8         <property name="maxWait" value="1000"/>
 9         <property name="defaultAutoCommit" value="true"/>
10         <property name="removeAbandoned" value="true"/>
11         <property name="removeAbandonedTimeout" value="60"/>
12     </bean>
13     
14     <bean id="qipaiDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
15         <property name="driverClassName" value="com.timesten.jdbc.TimesTenClientDriver"/>
16         <property name="url" value="jdbc:timesten:client:qipai"/>
17         <property name="username" value=""/>
18         <property name="password" value=""/>
19         <property name="maxActive" value="100"/>
20         <property name="maxIdle" value="30"/>
21         <property name="maxWait" value="1000"/>
22         <property name="defaultAutoCommit" value="true"/>
23         <property name="removeAbandoned" value="true"/>
24         <property name="removeAbandonedTimeout" value="60"/>
25     </bean>

posted @ 2007-07-26 10:06 llrafale 阅读(712) | 评论 (0) | 编辑 收藏
 
StringtoDate的方法
 1 public  Date toDay(String date) {
 2       DateFormat dateFormat=null;
 3       dateFormat = new SimpleDateFormat("yyyy-MM-dd");
 4       // dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 5      dateFormat.setLenient(false);
 6      try {
 7            Date day = dateFormat.parse(date);
 8            return day; 
 9      } catch (Exception e) {
10          e.printStackTrace();
11          return null;
12     }
13 }
14 
 
posted @ 2007-07-24 17:33 llrafale 阅读(949) | 评论 (0) | 编辑 收藏
 
定时统计
/** *//**
 * 定时统计在线人数
 
*/

public class PreTestSelRunner {
    
    
    
private static PreTestSel preTestSel;

    
/** *//**
     * 定时执行--静态方法(避免重复执行)

     * 
@param conn
     * 
@throws Exception
     
*/

    
public static void load() throws Exception {

        
//间隔时间设置,10分钟
        long period = 10*1000*60;
        
        PreTestSelRunner.preTestSel 
= new PreTestSel(period);
    }


    
/** *//**
     * 定时调用主方法

     * 
     * PreTestSel.run()
     
*/

    
public static void run() {

        
try {
            
            TkGameBeanFactoryPlugin BeanPlugin 
= TkGameBeanFactoryPlugin.getIntance();
            RuntimeSettingsPlugInBL runtimeSettingsPlugInBL 
= (RuntimeSettingsPlugInBL) BeanPlugin.getBean("runtimeSettingsPlugInBL");

            
            
try {
                
                
//增加统计在线人数记录
                List list = runtimeSettingsPlugInBL.getBRSsoByServer();
                
                
for(int i=0;i<list.size();i++){
                    
                    
                    Game12OnlineLog obj 
= new Game12OnlineLog();
                    obj.setLogtime(
new Date());
                    obj.setServerno(list.get(i).toString());
                    obj.setValue(Integer.parseInt(list.get(i
+1).toString()));
                    
                    runtimeSettingsPlugIn2BL.saveOnlineLog(obj);

                    i
=i+1;
                }

                
            }
 catch (Exception e) {
                
                e.printStackTrace();
            }
 

                
        }
 catch (Exception ex) {
            System.out.println(
"run() error!!");
        }


    }


    

}
/** *//**
 * 定时统计在线人数
 * 
 
*/

public class PreTestSel extends TimerTask {

    
private Timer timer;
    
    
/** *//**
     * 
     * 
@param firstTime
     * 
@throws Exception
     
*/

    
public PreTestSel(long period) throws Exception {
        
        
this.timer = new Timer(true);
        
this.timer.schedule(this, 0, period);
    }

    
    
public void destroy() {
        
        
this.timer.cancel();
    }


    
public void run() {
        
        PreTestSelRunner.run();
    }

}

posted @ 2007-07-24 17:17 llrafale 阅读(274) | 评论 (0) | 编辑 收藏
 
启动服务读取XML配置文件(解析XML)


commons-collections-3.1.jar
commons-configuration-1.2.jar
commons-lang.jar
commons-logging.jar


 1public class TankAndkCardPlugIn implements PlugIn {
 2
 3 public Map<String, Object> tankMap;
 4 
 5 public void destroy() {
 6 
 7 }

 8
 9 
10 public void init(ActionServlet actionServlet, ModuleConfig moduleConfig)
11   throws ServletException {
12  
13  ServletContext application = actionServlet.getServletContext();
14  
15    //读取tankshop.xml
16  try {
17   
18      URL url = Thread.currentThread().getContextClassLoader().getResource("tankshop.xml");
19  
20   XMLConfiguration configuration = new XMLConfiguration(url);
21   
22   List idList = configuration.getList("Table.Row.id");
23   List nameList = configuration.getList("Table.Row.name");
24   List picList = configuration.getList("Table.Row.picture");
25   List infoList = configuration.getList("Table.Row.info");
26   
27   tankMap = new HashMap<String, Object>();
28   
29   //解析xml
30      for(int i=0;i<nameList.size();i++){
31       
32       String id = (String)idList.get(i);
33       String name = (String)nameList.get(i);
34       String pic = (String)picList.get(i);
35       String info = (String)infoList.get(i);
36       
37       TankAndCardObjbean bean = new TankAndCardObjbean();
38       
39       bean.setId(id);
40       bean.setName(name);
41       bean.setPicture(pic);
42       bean.setInfo(info);
43       
44       tankMap.put(id+"", bean);
45    
46      }

47      
48      application.setAttribute("tankMap",tankMap);
49      
50      System.out.println("tankMap ok!!!!!!!!!!!!!!!!!!!!!");
51      
52  }
 catch (Exception e) {
53   
54   System.out.println("tankMap error************************");
55  }

56  
57  
58 }

59
60}

61
62
posted @ 2007-07-24 17:01 llrafale 阅读(420) | 评论 (0) | 编辑 收藏