<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet href="/xsl/rss.xsl" type="text/xsl" media="screen"?>
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:ppp="http://blog.sohu.com/rss/module/ppp/"
	>

	<channel>
		<title>幽灵特工</title>
		<link>http://wanglch200.blog.sohu.com/</link>
		<description><![CDATA[孙悟空: 师傅,跟我来...]]></description>
		<pubDate>Wed, 28 Mar 2007 14:42:30 +0800</pubDate>
		<generator>搜狐博客</generator>
		<ppp:ebi>b6eee76792</ppp:ebi>
		<image>
			<title>http://blog.sohu.com</title>
			<url>http://js.pp.sohu.com/ppp/blog/images/common/logo_150_60.gif</url>
			<link>http://blog.sohu.com/</link>
			<width>100</width>
			<height>43</height>
			<description>搜狐博客</description>
		</image>
		<item>
			<title>我自己的数据对象处理类 LoadRs2P</title>
			<link>http://wanglch200.blog.sohu.com/36097890.html</link>
			<comments>http://wanglch200.blog.sohu.com/36097890.html#comment</comments>
			<dc:creator>幽灵特工</dc:creator>
			<pubDate>Sat, 3 Mar 2007 14:22:04 +0800</pubDate>
			<category>数据库处理</category>
			<guid>http://wanglch200.blog.sohu.com/36097890.html</guid>
			<description><![CDATA[<p>package com.jh.core.db.jdbc;</p>
<p>import java.lang.reflect.Field;</p>
<p>import com.jh.app.util.CommUtil;</p>
<p>class LoadRs2P {<br />&nbsp;int columnType;</p>
<p>&nbsp;String columnName;</p>
<p>&nbsp;Field field;<br />/**<br />&nbsp;* 自动匹配列值<br />&nbsp;* @param rs<br />&nbsp;* @param obj<br />&nbsp;* @throws Exception<br />&nbsp;*/<br />&nbsp;public void set(java.sql.ResultSet rs, Object obj) throws Exception {</p>
<p>&nbsp;&nbsp;if (0 == (columnType)) {</p>
<p>&nbsp;&nbsp;} else if (ColumnType.TYPE_INTEGER == columnType) {<br />&nbsp;&nbsp;&nbsp;int iValue = rs.getInt(columnName);<br />&nbsp;&nbsp;&nbsp;if (iValue == 0) {</p>
<p>&nbsp;&nbsp;&nbsp;} else if (field.getType().equals(int.class)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;field.setInt(obj, iValue);<br />&nbsp;&nbsp;&nbsp;} else if (field.getType().equals(long.class)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;field.setLong(obj, iValue);<br />&nbsp;&nbsp;&nbsp;} else if (field.getType().equals(String.class)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;field.set(obj, &quot;&quot;+iValue);<br />&nbsp;&nbsp;&nbsp;} else if (field.getType().equals(double.class)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;field.setDouble(obj, iValue);<br />&nbsp;&nbsp;&nbsp;} else if (field.getType().equals(float.class)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;field.setFloat(obj, iValue);<br />&nbsp;&nbsp;&nbsp;} else if (field.getType().equals(java.util.Date.class)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;field.set(obj, new java.util.Date(iValue));<br />&nbsp;&nbsp;&nbsp;} else if (field.getType().equals(Long.class)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;field.set(obj, new Long(iValue));<br />&nbsp;&nbsp;&nbsp;} else if (field.getType().equals(Integer.class)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;field.set(obj, new Integer(iValue));<br />&nbsp;&nbsp;&nbsp;} else if (field.getType().equals(Double.class)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;field.set(obj, new Double(iValue));<br />&nbsp;&nbsp;&nbsp;} else if (field.getType().equals(Float.class)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;field.set(obj, new Float(iValue));<br />&nbsp;&nbsp;&nbsp;}</p>
<p>&nbsp;&nbsp;} else if (ColumnType.TYPE_LONG == (columnType)) {<br />&nbsp;&nbsp;&nbsp;long iValue = rs.getLong(columnName);<br />&nbsp;&nbsp;&nbsp;if (iValue == 0) {</p>
<p>&nbsp;&nbsp;&nbsp;} else if (field.getType().equals(long.class)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;field.setLong(obj, iValue);<br />&nbsp;&nbsp;&nbsp;} else if (field.getType().equals(String.class)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;field.set(obj, &quot;&quot;+iValue);<br />&nbsp;&nbsp;&nbsp;} else if (field.getType().equals(int.class)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;field.setInt(obj, (int) iValue);<br />&nbsp;&nbsp;&nbsp;} else if (field.getType().equals(double.class)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;field.setDouble(obj, iValue);<br />&nbsp;&nbsp;&nbsp;} else if (field.getType().equals(float.class)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;field.setFloat(obj, iValue);<br />&nbsp;&nbsp;&nbsp;} else if (field.getType().equals(java.util.Date.class)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;field.set(obj, new java.util.Date(iValue));<br />&nbsp;&nbsp;&nbsp;} else if (field.getType().equals(Long.class)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;field.set(obj, new Long(iValue));<br />&nbsp;&nbsp;&nbsp;} else if (field.getType().equals(Integer.class)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;field.set(obj, new Integer((int) iValue));<br />&nbsp;&nbsp;&nbsp;} else if (field.getType().equals(Double.class)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;field.set(obj, new Double(iValue));<br />&nbsp;&nbsp;&nbsp;} else if (field.getType().equals(Float.class)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;field.set(obj, new Float(iValue));<br />&nbsp;&nbsp;&nbsp;}</p>
<p>&nbsp;&nbsp;} else if (ColumnType.TYPE_TIMESTAMP == (columnType)) {<br />&nbsp;&nbsp;&nbsp;java.sql.Timestamp date = rs.getTimestamp(columnName);</p>
<p>&nbsp;&nbsp;&nbsp;if (date != null) {<br />&nbsp;&nbsp;&nbsp;&nbsp;if (field.getType().equals(java.util.Date.class)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;field.set(obj, new java.util.Date(date.getTime()));<br />&nbsp;&nbsp;&nbsp;&nbsp;} else if (field.getType().equals(String.class)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;field.set(obj, &quot;&quot; + date);<br />&nbsp;&nbsp;&nbsp;&nbsp;} else if (field.getType().equals(long.class)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;field.setLong(obj, date.getTime());<br />&nbsp;&nbsp;&nbsp;&nbsp;} else if (field.getType().equals(Long.class)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;field.set(obj, new Long(date.getTime()));<br />&nbsp;&nbsp;&nbsp;&nbsp;} else if (field.getType().equals(String.class)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;field.set(obj, &quot;&quot; + date);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;} else if (ColumnType.TYPE_STRING == (columnType)) {<br />&nbsp;&nbsp;&nbsp;String objValue = rs.getString(columnName);<br />&nbsp;&nbsp;&nbsp;if (objValue == null) {</p>
<p>&nbsp;&nbsp;&nbsp;} else if (field.getType().equals(String.class)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;field.set(obj, objValue);<br />&nbsp;&nbsp;&nbsp;} else if (field.getType().equals(long.class)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;field.setLong(obj, new Long(objValue));<br />&nbsp;&nbsp;&nbsp;} else if (field.getType().equals(int.class)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;field.setInt(obj, new Integer(objValue));<br />&nbsp;&nbsp;&nbsp;} else if (field.getType().equals(double.class)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;field.setDouble(obj, new Double(objValue));<br />&nbsp;&nbsp;&nbsp;} else if (field.getType().equals(float.class)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;field.setFloat(obj, new Float(objValue));<br />&nbsp;&nbsp;&nbsp;} else if (field.getType().equals(java.util.Date.class)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;field.set(obj, CommUtil.formatDate(objValue));<br />&nbsp;&nbsp;&nbsp;} else if (field.getType().equals(Long.class)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;field.set(obj, new Long(objValue));<br />&nbsp;&nbsp;&nbsp;} else if (field.getType().equals(Integer.class)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;field.set(obj, new Integer(objValue));<br />&nbsp;&nbsp;&nbsp;} else if (field.getType().equals(Double.class)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;field.set(obj, new Double(objValue));<br />&nbsp;&nbsp;&nbsp;} else if (field.getType().equals(Float.class)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;field.set(obj, new Float(objValue));<br />&nbsp;&nbsp;&nbsp;}</p>
<p>&nbsp;&nbsp;} else if (ColumnType.TYPE_DOUBLE == (columnType)) {<br />&nbsp;&nbsp;&nbsp;double iValue = rs.getDouble(columnName);<br />&nbsp;&nbsp;&nbsp;if (field.getType().equals(double.class)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;field.setDouble(obj, new Double(iValue));<br />&nbsp;&nbsp;&nbsp;} else if (field.getType().equals(float.class)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;field.setFloat(obj, new Float((float) iValue));<br />&nbsp;&nbsp;&nbsp;} else if (field.getType().equals(String.class)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;field.set(obj, &quot;&quot;+iValue);<br />&nbsp;&nbsp;&nbsp;} else if (field.getType().equals(long.class)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;field.setLong(obj, new Long((long) iValue));<br />&nbsp;&nbsp;&nbsp;} else if (field.getType().equals(int.class)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;field.setInt(obj, new Integer((int) iValue));<br />&nbsp;&nbsp;&nbsp;} else if (field.getType().equals(Long.class)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;field.set(obj, new Long((long) iValue));<br />&nbsp;&nbsp;&nbsp;} else if (field.getType().equals(Integer.class)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;field.set(obj, new Integer((int) iValue));<br />&nbsp;&nbsp;&nbsp;} else if (field.getType().equals(Double.class)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;field.set(obj, new Double(iValue));<br />&nbsp;&nbsp;&nbsp;} else if (field.getType().equals(Float.class)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;field.set(obj, new Float((float) iValue));<br />&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;} else if (ColumnType.TYPE_BIGDECIMAL == (columnType)) {<br />&nbsp;&nbsp;&nbsp;java.math.BigDecimal iValue = rs.getBigDecimal(columnName);<br />&nbsp;&nbsp;&nbsp;if (iValue == null) {</p>
<p>&nbsp;&nbsp;&nbsp;} else if (field.getType().equals(double.class)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;field.setDouble(obj, iValue.doubleValue());<br />&nbsp;&nbsp;&nbsp;} else if (field.getType().equals(float.class)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;field.setFloat(obj, iValue.floatValue());<br />&nbsp;&nbsp;&nbsp;} else if (field.getType().equals(String.class)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;field.set(obj, &quot;&quot;+iValue);<br />&nbsp;&nbsp;&nbsp;} else if (field.getType().equals(long.class)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;field.setLong(obj, iValue.longValue());<br />&nbsp;&nbsp;&nbsp;} else if (field.getType().equals(int.class)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;field.setInt(obj, iValue.intValue());<br />&nbsp;&nbsp;&nbsp;} else if (field.getType().equals(Long.class)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;field.set(obj, new Long(iValue.longValue()));<br />&nbsp;&nbsp;&nbsp;} else if (field.getType().equals(Integer.class)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;field.set(obj, new Integer(iValue.intValue()));<br />&nbsp;&nbsp;&nbsp;} else if (field.getType().equals(Double.class)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;field.set(obj, new Double(iValue.doubleValue()));<br />&nbsp;&nbsp;&nbsp;} else if (field.getType().equals(Float.class)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;field.set(obj, new Float(iValue.floatValue()));<br />&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;}<br />&nbsp;}</p>
<p>}<br /></p>]]></description>
		</item>
		    
		
		<item>
			<title>我自己的数据对象处理类 DBConnection</title>
			<link>http://wanglch200.blog.sohu.com/36097730.html</link>
			<comments>http://wanglch200.blog.sohu.com/36097730.html#comment</comments>
			<dc:creator>幽灵特工</dc:creator>
			<pubDate>Sat, 3 Mar 2007 14:22:59 +0800</pubDate>
			<category>数据库处理</category>
			<guid>http://wanglch200.blog.sohu.com/36097730.html</guid>
			<description><![CDATA[<p>package com.jh.core.db.jdbc;</p>
<p>import java.sql.Connection;<br />import java.sql.PreparedStatement;<br />import java.sql.SQLException;<br />import java.util.Date;<br />import java.util.HashMap;<br />import java.util.Map;</p>
<p>import javax.sql.DataSource;</p>
<p>import com.jh.app.util.Globle;<br />import com.mchange.v2.c3p0.DataSources;</p>
<p>public class DBConnection {<br />&nbsp;&nbsp;&nbsp; private static Map&lt;String ,DataSource&gt; dsMap=new&nbsp; HashMap&lt;String ,DataSource&gt;();;</p>
<p>&nbsp;&nbsp;&nbsp; synchronized static public DataSource dataSource(String dbName) {<br />&nbsp;&nbsp;if (dsMap.get(dbName) == null)<br />&nbsp;&nbsp;&nbsp;try {<br />&nbsp;&nbsp;&nbsp;&nbsp;if(Globle.CMS_DB.equals(dbName)){<br />&nbsp;&nbsp;&nbsp;&nbsp;Class.forName(&quot;com.mysql.jdbc.Driver&quot;);<br />&nbsp;&nbsp;&nbsp;&nbsp;String url=&quot;jdbc:mysql://192.168.3.41:3306/&quot;+dbName+&quot;?useUnicode=true&amp;characterEncoding=GBK&quot;;;<br />&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(&quot;url=&quot;+url);<br />&nbsp;&nbsp;&nbsp;&nbsp;DataSource unpooled = DataSources.unpooledDataSource(url,&quot;root&quot;, &quot;123456&quot;);<br />&nbsp;&nbsp;&nbsp;&nbsp;DataSource&nbsp;ds = DataSources.pooledDataSource(unpooled);<br />&nbsp;&nbsp;&nbsp;&nbsp;dsMap.put(dbName, ds);<br />&nbsp;&nbsp;&nbsp;&nbsp;}else&nbsp; if(Globle.TAG_DB.equals(dbName)){<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Class.forName(&quot;com.mysql.jdbc.Driver&quot;);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String url=&quot;jdbc:mysql://192.168.3.53:3306/&quot;+dbName+&quot;?useUnicode=true&amp;characterEncoding=GBK&quot;;;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(&quot;url=&quot;+url);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DataSource unpooled = DataSources.unpooledDataSource(url,&quot;root&quot;, &quot;&quot;);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DataSource&nbsp;ds = DataSources.pooledDataSource(unpooled);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dsMap.put(dbName, ds);&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;}else{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Class.forName(&quot;com.mysql.jdbc.Driver&quot;);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String url=&quot;jdbc:mysql://192.168.3.94:3306/&quot;+dbName+&quot;?useUnicode=true&amp;characterEncoding=GBK&quot;;;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(&quot;url=&quot;+url);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DataSource unpooled = DataSources.unpooledDataSource(url,&quot;root&quot;, &quot;123456&quot;);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DataSource&nbsp;ds = DataSources.pooledDataSource(unpooled);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dsMap.put(dbName, ds);&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;} catch (Exception e) {<br />&nbsp;&nbsp;&nbsp;&nbsp;e.printStackTrace();<br />&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;return dsMap.get(dbName);<br />&nbsp;}</p>
<p>&nbsp;</p>
<p>&nbsp;// base close connection.<br />&nbsp;public static void closeDBConnection(Connection conn) {<br />&nbsp;&nbsp;try {<br />&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;if (conn != null) {<br />&nbsp;&nbsp;&nbsp;&nbsp;conn.close();<br />&nbsp;&nbsp;&nbsp;&nbsp;conn = null;<br />&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;} catch (Exception e) {<br />&nbsp;&nbsp;&nbsp;// 标签<br />&nbsp;&nbsp;&nbsp;e.printStackTrace();<br />&nbsp;&nbsp;}<br />&nbsp;&nbsp;<br />&nbsp;}</p>
<p>&nbsp;public static void closeDBPrepared(PreparedStatement ps) {<br />&nbsp;&nbsp;try {<br />&nbsp;&nbsp;&nbsp;if (ps != null) {<br />&nbsp;&nbsp;&nbsp;&nbsp;ps.close();<br />&nbsp;&nbsp;&nbsp;&nbsp;ps = null;<br />&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;} catch (Exception e) {<br />&nbsp;&nbsp;&nbsp;e.printStackTrace();<br />&nbsp;&nbsp;}</p>
<p>&nbsp;}</p>
<p>&nbsp;public static Connection getDBConnection(String dbName) {<br />&nbsp;&nbsp;Connection conn = null;<br />&nbsp;&nbsp;DataSource ds = dataSource(dbName);<br />&nbsp;&nbsp;try {<br />&nbsp;&nbsp;&nbsp;conn = ds.getConnection();<br />&nbsp;&nbsp;} catch (SQLException e) {<br />&nbsp;&nbsp;}<br />&nbsp;&nbsp;//logger.debug(&quot;返回数据库链接:&quot; + conn);<br />&nbsp;&nbsp;return conn;<br />&nbsp;}<br />&nbsp;public static void main(String args[]) throws Exception{<br />&nbsp; long time=System.currentTimeMillis();<br />&nbsp;&nbsp;System.out.println(getDBConnection(&quot;TagDB&quot;));<br />&nbsp;&nbsp;System.out.println(System.currentTimeMillis()-time);<br />&nbsp;&nbsp;<br />&nbsp;}<br />}<br /></p>]]></description>
		</item>
		    
		
		<item>
			<title>我自己的数据对象处理类 DBCallBack</title>
			<link>http://wanglch200.blog.sohu.com/36095535.html</link>
			<comments>http://wanglch200.blog.sohu.com/36095535.html#comment</comments>
			<dc:creator>幽灵特工</dc:creator>
			<pubDate>Sat, 3 Mar 2007 14:23:16 +0800</pubDate>
			<category>数据库处理</category>
			<guid>http://wanglch200.blog.sohu.com/36095535.html</guid>
			<description><![CDATA[<p>package com.jh.core.db.jdbc;</p>
<p>import java.sql.Connection;</p>
<p>abstract class DBCallBack&lt;T&gt; {</p>
<p>&nbsp;public abstract Object execute(Connection conn) throws Exception;<br />}<br /></p>]]></description>
		</item>
		    
		
		<item>
			<title>我自己的数据对象处理类 ColumnType</title>
			<link>http://wanglch200.blog.sohu.com/36095416.html</link>
			<comments>http://wanglch200.blog.sohu.com/36095416.html#comment</comments>
			<dc:creator>幽灵特工</dc:creator>
			<pubDate>Sat, 3 Mar 2007 14:23:25 +0800</pubDate>
			<category>数据库处理</category>
			<guid>http://wanglch200.blog.sohu.com/36095416.html</guid>
			<description><![CDATA[<p>package com.jh.core.db.jdbc;</p>
<p><br />final&nbsp; class ColumnType {<br />&nbsp;public final static int TYPE_OTHER = 0;</p>
<p>&nbsp;public final static int TYPE_INTEGER = 1;</p>
<p>&nbsp;public final static int TYPE_LONG = 2;</p>
<p>&nbsp;public final static int TYPE_TIMESTAMP = 3;</p>
<p>&nbsp;public final static int TYPE_STRING = 4;</p>
<p>&nbsp;public final static int TYPE_DOUBLE = 5;</p>
<p>&nbsp;public final static int TYPE_BIGDECIMAL = 6;</p>
<p>&nbsp;public static int getType(String columnType) {<br />&nbsp;&nbsp;int i = TYPE_OTHER;</p>
<p>&nbsp;&nbsp;if (&quot;java.lang.Integer&quot;.equals(columnType)) {<br />&nbsp;&nbsp;&nbsp;return TYPE_INTEGER;<br />&nbsp;&nbsp;}<br />&nbsp;&nbsp;if (&quot;java.lang.Long&quot;.equals(columnType)) {<br />&nbsp;&nbsp;&nbsp;return TYPE_LONG;<br />&nbsp;&nbsp;}<br />&nbsp;&nbsp;if (&quot;java.sql.Timestamp&quot;.equals(columnType)) {<br />&nbsp;&nbsp;&nbsp;return TYPE_TIMESTAMP;<br />&nbsp;&nbsp;}<br />&nbsp;&nbsp;if (&quot;java.lang.String&quot;.equals(columnType)) {<br />&nbsp;&nbsp;&nbsp;return TYPE_STRING;<br />&nbsp;&nbsp;}<br />&nbsp;&nbsp;if (&quot;java.lang.Double&quot;.equals(columnType)) {<br />&nbsp;&nbsp;&nbsp;return TYPE_DOUBLE;<br />&nbsp;&nbsp;}<br />&nbsp;&nbsp;if (&quot;java.math.BigDecimal&quot;.equals(columnType)) {<br />&nbsp;&nbsp;&nbsp;return TYPE_BIGDECIMAL;<br />&nbsp;&nbsp;}</p>
<p>&nbsp;&nbsp;return i;</p>
<p>&nbsp;}</p>
<p>}<br /></p>]]></description>
		</item>
		    
		
		<item>
			<title>mysql 时间的相关处理</title>
			<link>http://wanglch200.blog.sohu.com/36094948.html</link>
			<comments>http://wanglch200.blog.sohu.com/36094948.html#comment</comments>
			<dc:creator>幽灵特工</dc:creator>
			<pubDate>Sat, 3 Mar 2007 14:23:56 +0800</pubDate>
			<category>数据库处理</category>
			<guid>http://wanglch200.blog.sohu.com/36094948.html</guid>
			<description><![CDATA[<p><span></span>&nbsp;</p>
<p><span>mysql 时间处理</span><br /><br />Mysql日期和时间函数不求人 <br /></p>
<div style="FONT-SIZE: 12px">select TO_DAYS(CURDATE())- TO_DAYS('2007-01-01');&nbsp; &nbsp;查询某时间距现在的天数<br /><br /><br /><br /><br /><br />对于每个类型拥有的值范围以及并且指定日期何时间值的有效格式的描述见7.3.6 日期和时间类型。&nbsp;&nbsp;<br />这里是一个使用日期函数的例子。下面的查询选择了所有记录，其date_col的值是在最后30天以内：&nbsp;&nbsp;<br />mysql&gt; SELECT something FROM table&nbsp;&nbsp;<br />WHERE TO_DAYS(NOW()) - TO_DAYS(date_col) &lt;= 30;&nbsp;&nbsp;<br />DAYOFWEEK(date)&nbsp;&nbsp;<br />返回日期date的星期索引(1=星期天，2=星期一, &hellip;&hellip;7=星期六)。这些索引值对应于ODBC标准。&nbsp;&nbsp;<br />mysql&gt; select DAYOFWEEK('1998-02-03');&nbsp;&nbsp;<br />-&gt; 3&nbsp;&nbsp;<br />WEEKDAY(date)&nbsp;&nbsp;<br />返回date的星期索引(0=星期一，1=星期二, &hellip;&hellip;6= 星期天)。&nbsp;&nbsp;<br />mysql&gt; select WEEKDAY('1997-10-04 22:23:00');&nbsp;&nbsp;<br />-&gt; 5&nbsp;&nbsp;<br />mysql&gt; select WEEKDAY('1997-11-05');&nbsp;&nbsp;<br />-&gt; 2&nbsp;&nbsp;<br />DAYOFMONTH(date)&nbsp;&nbsp;<br />返回date的月份中日期，在1到31范围内。&nbsp;&nbsp;<br />mysql&gt; select DAYOFMONTH('1998-02-03');&nbsp;&nbsp;<br />-&gt; 3&nbsp;&nbsp;<br />DAYOFYEAR(date)&nbsp;&nbsp;<br />返回date在一年中的日数, 在1到366范围内。&nbsp;&nbsp;<br />mysql&gt; select DAYOFYEAR('1998-02-03');&nbsp;&nbsp;<br />-&gt; 34&nbsp;&nbsp;<br />MONTH(date)&nbsp;&nbsp;<br />返回date的月份，范围1到12。&nbsp;&nbsp;<br />mysql&gt; select MONTH('1998-02-03');&nbsp;&nbsp;<br />-&gt; 2&nbsp;&nbsp;<br />DAYNAME(date)&nbsp;&nbsp;<br />返回date的星期名字。&nbsp;&nbsp;<br />mysql&gt; select DAYNAME(&quot;1998-02-05&quot;);&nbsp;&nbsp;<br />-&gt; 'Thursday'&nbsp;&nbsp;<br />MONTHNAME(date)&nbsp;&nbsp;<br />返回date的月份名字。&nbsp;&nbsp;<br />mysql&gt; select MONTHNAME(&quot;1998-02-05&quot;);&nbsp;&nbsp;<br />-&gt; 'February'&nbsp;&nbsp;<br />QUARTER(date)&nbsp;&nbsp;<br />返回date一年中的季度，范围1到4。&nbsp;&nbsp;<br />mysql&gt; select QUARTER('98-04-01');&nbsp;&nbsp;<br />-&gt; 2&nbsp;&nbsp;<br />WEEK(date)&nbsp;&nbsp;<br />　&nbsp;&nbsp;<br />WEEK(date,first)&nbsp;&nbsp;<br />对于星期天是一周的第一天的地方，有一个单个参数，返回date的周数，范围在0到52。2个参数形式WEEK()允许 <br />你指定星期是否开始于星期天或星期一。如果第二个参数是0，星期从星期天开始，如果第二个参数是1， <br />从星期一开始。&nbsp;&nbsp;<br />mysql&gt; select WEEK('1998-02-20');&nbsp;&nbsp;<br />-&gt; 7&nbsp;&nbsp;<br />mysql&gt; select WEEK('1998-02-20',0);&nbsp;&nbsp;<br />-&gt; 7&nbsp;&nbsp;<br />mysql&gt; select WEEK('1998-02-20',1);&nbsp;&nbsp;<br />-&gt; 8&nbsp;&nbsp;<br />YEAR(date)&nbsp;&nbsp;<br />返回date的年份，范围在1000到9999。&nbsp;&nbsp;<br />mysql&gt; select YEAR('98-02-03');&nbsp;&nbsp;<br />-&gt; 1998&nbsp;&nbsp;<br />HOUR(time)&nbsp;&nbsp;<br />返回time的小时，范围是0到23。&nbsp;&nbsp;<br />mysql&gt; select HOUR('10:05:03');&nbsp;&nbsp;<br />-&gt; 10&nbsp;&nbsp;<br />MINUTE(time)&nbsp;&nbsp;<br />返回time的分钟，范围是0到59。&nbsp;&nbsp;<br />mysql&gt; select MINUTE('98-02-03 10:05:03');&nbsp;&nbsp;<br />-&gt; 5&nbsp;&nbsp;<br />SECOND(time)&nbsp;&nbsp;<br />回来time的秒数，范围是0到59。&nbsp;&nbsp;<br />mysql&gt; select SECOND('10:05:03');&nbsp;&nbsp;<br />-&gt; 3&nbsp;&nbsp;<br />PERIOD_ADD(P,N)&nbsp;&nbsp;<br />增加N个月到阶段P（以格式YYMM或YYYYMM)。以格式YYYYMM返回值。注意阶段参数P不是日期值。&nbsp;&nbsp;<br />mysql&gt; select PERIOD_ADD(9801,2);&nbsp;&nbsp;<br />-&gt; 199803&nbsp;&nbsp;<br />PERIOD_DIFF(P1,P2)&nbsp;&nbsp;<br />返回在时期P1和P2之间月数，P1和P2应该以格式YYMM或YYYYMM。注意，时期参数P1和P2不是日期值。&nbsp;&nbsp;<br />mysql&gt; select PERIOD_DIFF(9802,199703);&nbsp;&nbsp;<br />-&gt; 11&nbsp;&nbsp;<br />DATE_ADD(date,INTERVAL expr type)&nbsp;&nbsp;<br />　&nbsp;&nbsp;<br />DATE_SUB(date,INTERVAL expr type)&nbsp;&nbsp;<br />　&nbsp;&nbsp;<br />ADDDATE(date,INTERVAL expr type)&nbsp;&nbsp;<br />　&nbsp;&nbsp;<br />SUBDATE(date,INTERVAL expr type)&nbsp;&nbsp;<br />这些功能执行日期运算。对于MySQL 3.22，他们是新的。ADDDATE()和SUBDATE()是DATE_ADD()和DATE_SUB()的同义词。 <br />在MySQL 3.23中，你可以使用+和-而不是DATE_ADD()和DATE_SUB()。（见例子）date是一个指定开始日期的 <br />DATETIME或DATE值，expr是指定加到开始日期或从开始日期减去的间隔值一个表达式，expr是一个字符串；它可以以 <br />一个&ldquo;-&rdquo;开始表示负间隔。type是一个关键词，指明表达式应该如何被解释。EXTRACT(type FROM date)函数从日期 <br />中返回&ldquo;type&rdquo;间隔。下表显示了type和expr参数怎样被关联： type值 含义 期望的expr格式&nbsp;&nbsp;<br />SECOND 秒 SECONDS&nbsp;&nbsp;<br />MINUTE 分钟 MINUTES&nbsp;&nbsp;<br />HOUR 时间 HOURS&nbsp;&nbsp;<br />DAY 天 DAYS&nbsp;&nbsp;<br />MONTH 月 MONTHS&nbsp;&nbsp;<br />YEAR 年 YEARS&nbsp;&nbsp;<br />MINUTE_SECOND 分钟和秒 &quot;MINUTES:SECONDS&quot;&nbsp;&nbsp;<br />HOUR_MINUTE 小时和分钟 &quot;HOURS:MINUTES&quot;&nbsp;&nbsp;<br />DAY_HOUR 天和小时 &quot;DAYS HOURS&quot;&nbsp;&nbsp;<br />YEAR_MONTH 年和月 &quot;YEARS-MONTHS&quot;&nbsp;&nbsp;<br />HOUR_SECOND 小时, 分钟， &quot;HOURS:MINUTES:SECONDS&quot;&nbsp;&nbsp;<br />DAY_MINUTE 天, 小时, 分钟 &quot;DAYS HOURS:MINUTES&quot;&nbsp;&nbsp;<br />DAY_SECOND 天, 小时, 分钟, 秒 &quot;DAYS HOURS:MINUTES:SECONDS&quot;&nbsp;&nbsp;<br />MySQL在expr格式中允许任何标点分隔符。表示显示的是建议的分隔符。如果date参数是一个DATE值并且你的计算仅仅 <br />包含YEAR、MONTH和DAY部分(即，没有时间部分)，结果是一个DATE值。否则结果是一个DATETIME值。&nbsp;&nbsp;<br />mysql&gt; SELECT &quot;1997-12-31 23:59:59&quot; + INTERVAL 1 SECOND;&nbsp;&nbsp;<br />-&gt; 1998-01-01 00:00:00&nbsp;&nbsp;<br />mysql&gt; SELECT INTERVAL 1 DAY + &quot;1997-12-31&quot;;&nbsp;&nbsp;<br />-&gt; 1998-01-01&nbsp;&nbsp;<br />mysql&gt; SELECT &quot;1998-01-01&quot; - INTERVAL 1 SECOND;&nbsp;&nbsp;<br />-&gt; 1997-12-31 23:59:59&nbsp;&nbsp;<br />mysql&gt; SELECT DATE_ADD(&quot;1997-12-31 23:59:59&quot;,&nbsp;&nbsp;<br />INTERVAL 1 SECOND);&nbsp;&nbsp;<br />-&gt; 1998-01-01 00:00:00&nbsp;&nbsp;<br />mysql&gt; SELECT DATE_ADD(&quot;1997-12-31 23:59:59&quot;,&nbsp;&nbsp;<br />INTERVAL 1 DAY);&nbsp;&nbsp;<br />-&gt; 1998-01-01 23:59:59&nbsp;&nbsp;<br />mysql&gt; SELECT DATE_ADD(&quot;1997-12-31 23:59:59&quot;,&nbsp;&nbsp;<br />INTERVAL &quot;1:1&quot; MINUTE_SECOND);&nbsp;&nbsp;<br />-&gt; 1998-01-01 00:01:00&nbsp;&nbsp;<br />mysql&gt; SELECT DATE_SUB(&quot;1998-01-01 00:00:00&quot;,&nbsp;&nbsp;<br />INTERVAL &quot;1 1:1:1&quot; DAY_SECOND);&nbsp;&nbsp;<br />-&gt; 1997-12-30 22:58:59&nbsp;&nbsp;<br />mysql&gt; SELECT DATE_ADD(&quot;1998-01-01 00:00:00&quot;,&nbsp;&nbsp;<br />INTERVAL &quot;-1 10&quot; DAY_HOUR);&nbsp;&nbsp;<br />-&gt; 1997-12-30 14:00:00&nbsp;&nbsp;<br />mysql&gt; SELECT DATE_SUB(&quot;1998-01-02&quot;, INTERVAL 31 DAY);&nbsp;&nbsp;<br />-&gt; 1997-12-02&nbsp;&nbsp;<br />mysql&gt; SELECT EXTRACT(YEAR FROM &quot;1999-07-02&quot;);&nbsp;&nbsp;<br />-&gt; 1999&nbsp;&nbsp;<br />mysql&gt; SELECT EXTRACT(YEAR_MONTH FROM &quot;1999-07-02 01:02:03&quot;);&nbsp;&nbsp;<br />-&gt; 199907&nbsp;&nbsp;<br />mysql&gt; SELECT EXTRACT(DAY_MINUTE FROM &quot;1999-07-02 01:02:03&quot;);&nbsp;&nbsp;<br />-&gt; 20102&nbsp;&nbsp;<br />如果你指定太短的间隔值(不包括type关键词期望的间隔部分)，MySQL假设你省掉了间隔值的最左面部分。例如， <br />如果你指定一个type是DAY_SECOND，值expr被希望有天、小时、分钟和秒部分。如果你象&quot;1:10&quot;这样指定值， <br />MySQL假设日子和小时部分是丢失的并且值代表分钟和秒。换句话说，&quot;1:10&quot; DAY_SECOND以它等价于&quot;1:10&quot; MINUTE_SECOND <br />的方式解释，这对那MySQL解释TIME值表示经过的时间而非作为一天的时间的方式有二义性。如果你使用确实不正确的日期， <br />结果是NULL。如果你增加MONTH、YEAR_MONTH或YEAR并且结果日期大于新月份的最大值天数，日子在新月用最大的天调整。&nbsp;&nbsp;<br />mysql&gt; select DATE_ADD('1998-01-30', Interval 1 month);&nbsp;&nbsp;<br />-&gt; 1998-02-28&nbsp;&nbsp;<br />注意，从前面的例子中词INTERVAL和type关键词不是区分大小写的。&nbsp;&nbsp;<br />TO_DAYS(date)&nbsp;&nbsp;<br />给出一个日期date，返回一个天数(从0年的天数)。&nbsp;&nbsp;<br />mysql&gt; select TO_DAYS(950501);&nbsp;&nbsp;<br />-&gt; 728779&nbsp;&nbsp;<br />mysql&gt; select TO_DAYS('1997-10-07');&nbsp;&nbsp;<br />-&gt; 729669&nbsp;&nbsp;<br />TO_DAYS()不打算用于使用格列高里历(1582)出现前的值。&nbsp;&nbsp;<br />FROM_DAYS(N)&nbsp;&nbsp;<br />给出一个天数N，返回一个DATE值。&nbsp;&nbsp;<br />mysql&gt; select FROM_DAYS(729669);&nbsp;&nbsp;<br />-&gt; '1997-10-07'&nbsp;&nbsp;<br />TO_DAYS()不打算用于使用格列高里历(1582)出现前的值。&nbsp;&nbsp;<br />DATE_FORMAT(date,format)&nbsp;&nbsp;<br />根据format字符串格式化date值。下列修饰符可以被用在format字符串中： %M 月名字(January&hellip;&hellip;December)&nbsp;&nbsp;<br />%W 星期名字(Sunday&hellip;&hellip;Saturday)&nbsp;&nbsp;<br />%D 有英语前缀的月份的日期(1st, 2nd, 3rd, 等等。）&nbsp;&nbsp;<br />%Y 年, 数字, 4 位&nbsp;&nbsp;<br />%y 年, 数字, 2 位&nbsp;&nbsp;<br />%a 缩写的星期名字(Sun&hellip;&hellip;Sat)&nbsp;&nbsp;<br />%d 月份中的天数, 数字(00&hellip;&hellip;31)&nbsp;&nbsp;<br />%e 月份中的天数, 数字(0&hellip;&hellip;31)&nbsp;&nbsp;<br />%m 月, 数字(01&hellip;&hellip;12)&nbsp;&nbsp;<br />%c 月, 数字(1&hellip;&hellip;12)&nbsp;&nbsp;<br />%b 缩写的月份名字(Jan&hellip;&hellip;Dec)&nbsp;&nbsp;<br />%j 一年中的天数(001&hellip;&hellip;366)&nbsp;&nbsp;<br />%H 小时(00&hellip;&hellip;23)&nbsp;&nbsp;<br />%k 小时(0&hellip;&hellip;23)&nbsp;&nbsp;<br />%h 小时(01&hellip;&hellip;12)&nbsp;&nbsp;<br />%I 小时(01&hellip;&hellip;12)&nbsp;&nbsp;<br />%l 小时(1&hellip;&hellip;12)&nbsp;&nbsp;<br />%i 分钟, 数字(00&hellip;&hellip;59)&nbsp;&nbsp;<br />%r 时间,12 小时(hh:mm:ss [AP]M)&nbsp;&nbsp;<br />%T 时间,24 小时(hh:mm:ss)&nbsp;&nbsp;<br />%S 秒(00&hellip;&hellip;59)&nbsp;&nbsp;<br />%s 秒(00&hellip;&hellip;59)&nbsp;&nbsp;<br />%p AM或PM&nbsp;&nbsp;<br />%w 一个星期中的天数(0=Sunday &hellip;&hellip;6=Saturday ）&nbsp;&nbsp;<br />%U 星期(0&hellip;&hellip;52), 这里星期天是星期的第一天&nbsp;&nbsp;<br />%u 星期(0&hellip;&hellip;52), 这里星期一是星期的第一天&nbsp;&nbsp;<br />%% 一个文字&ldquo;%&rdquo;。&nbsp;&nbsp;<br />所有的其他字符不做解释被复制到结果中。&nbsp;&nbsp;<br />mysql&gt; select DATE_FORMAT('1997-10-04 22:23:00', '%W %M %Y');&nbsp;&nbsp;<br />-&gt; 'Saturday October 1997'&nbsp;&nbsp;<br />mysql&gt; select DATE_FORMAT('1997-10-04 22:23:00', '%H:%i:%s');&nbsp;&nbsp;<br />-&gt; '22:23:00'&nbsp;&nbsp;<br />mysql&gt; select DATE_FORMAT('1997-10-04 22:23:00',&nbsp;&nbsp;<br />'%D %y %a %d %m %b %j');&nbsp;&nbsp;<br />-&gt; '4th 97 Sat 04 10 Oct 277'&nbsp;&nbsp;<br />mysql&gt; select DATE_FORMAT('1997-10-04 22:23:00',&nbsp;&nbsp;<br />'%H %k %I %r %T %S %w');&nbsp;&nbsp;<br />-&gt; '22 22 10 10:23:00 PM 22:23:00 00 6'&nbsp;&nbsp;<br />MySQL3.23中，在格式修饰符字符前需要%。在MySQL更早的版本中，%是可选的。&nbsp;&nbsp;<br />TIME_FORMAT(time,format)&nbsp;&nbsp;<br />这象上面的DATE_FORMAT()函数一样使用，但是format字符串只能包含处理小时、分钟和秒的那些格式修饰符。 <br />其他修饰符产生一个NULL值或0。&nbsp;&nbsp;<br />CURDATE()&nbsp;&nbsp;<br />　&nbsp;&nbsp;<br />CURRENT_DATE&nbsp;&nbsp;<br />以'YYYY-MM-DD'或YYYYMMDD格式返回今天日期值，取决于函数是在一个字符串还是数字上下文被使用。&nbsp;&nbsp;<br />mysql&gt; select CURDATE();&nbsp;&nbsp;<br />-&gt; '1997-12-15'&nbsp;&nbsp;<br />mysql&gt; select CURDATE() + 0;&nbsp;&nbsp;<br />-&gt; 19971215&nbsp;&nbsp;<br />CURTIME()&nbsp;&nbsp;<br />　&nbsp;&nbsp;<br />CURRENT_TIME&nbsp;&nbsp;<br />以'HH:MM:SS'或HHMMSS格式返回当前时间值，取决于函数是在一个字符串还是在数字的上下文被使用。&nbsp;&nbsp;<br />mysql&gt; select CURTIME();&nbsp;&nbsp;<br />-&gt; '23:50:26'&nbsp;&nbsp;<br />mysql&gt; select CURTIME() + 0;&nbsp;&nbsp;<br />-&gt; 235026&nbsp;&nbsp;<br />NOW()&nbsp;&nbsp;<br />　&nbsp;&nbsp;<br />SYSDATE()&nbsp;&nbsp;<br />　&nbsp;&nbsp;<br />CURRENT_TIMESTAMP&nbsp;&nbsp;<br />以'YYYY-MM-DD HH:MM:SS'或YYYYMMDDHHMMSS格式返回当前的日期和时间，取决于函数是在一个字符串还是在数字的 <br />上下文被使用。&nbsp;&nbsp;<br />mysql&gt; select NOW();&nbsp;&nbsp;<br />-&gt; '1997-12-15 23:50:26'&nbsp;&nbsp;<br />mysql&gt; select NOW() + 0;&nbsp;&nbsp;<br />-&gt; 19971215235026&nbsp;&nbsp;<br />UNIX_TIMESTAMP()&nbsp;&nbsp;<br />　&nbsp;&nbsp;<br />UNIX_TIMESTAMP(date)&nbsp;&nbsp;<br />如果没有参数调用，返回一个Unix时间戳记(从'1970-01-01 00:00:00'GMT开始的秒数)。如果UNIX_TIMESTAMP()用一 <br />个date参数被调用，它返回从'1970-01-01 00:00:00' GMT开始的秒数值。date可以是一个DATE字符串、一个DATETIME <br />字符串、一个TIMESTAMP或以YYMMDD或YYYYMMDD格式的本地时间的一个数字。&nbsp;&nbsp;<br />mysql&gt; select UNIX_TIMESTAMP();&nbsp;&nbsp;<br />-&gt; 882226357&nbsp;&nbsp;<br />mysql&gt; select UNIX_TIMESTAMP('1997-10-04 22:23:00');&nbsp;&nbsp;<br />-&gt; 875996580&nbsp;&nbsp;<br />当UNIX_TIMESTAMP被用于一个TIMESTAMP列，函数将直接接受值，没有隐含的&ldquo;string-to-unix-timestamp&rdquo;变换。&nbsp;&nbsp;<br />FROM_UNIXTIME(unix_timestamp)&nbsp;&nbsp;<br />以'YYYY-MM-DD HH:MM:SS'或YYYYMMDDHHMMSS格式返回unix_timestamp参数所表示的值，取决于函数是在一个字符串 <br />还是或数字上下文中被使用。&nbsp;&nbsp;<br />mysql&gt; select FROM_UNIXTIME(875996580);&nbsp;&nbsp;<br />-&gt; '1997-10-04 22:23:00'&nbsp;&nbsp;<br />mysql&gt; select FROM_UNIXTIME(875996580) + 0;&nbsp;&nbsp;<br />-&gt; 19971004222300&nbsp;&nbsp;<br />FROM_UNIXTIME(unix_timestamp,format)&nbsp;&nbsp;<br />返回表示 Unix 时间标记的一个字符串，根据format字符串格式化。format可以包含与DATE_FORMAT()函数列出的条 <br />目同样的修饰符。&nbsp;&nbsp;<br />mysql&gt; select FROM_UNIXTIME(UNIX_TIMESTAMP(),&nbsp;&nbsp;<br />'%Y %D %M %h:%i:%s %x');&nbsp;&nbsp;<br />-&gt; '1997 23rd December 03:43:30 x'&nbsp;&nbsp;<br />SEC_TO_TIME(seconds)&nbsp;&nbsp;<br />返回seconds参数，变换成小时、分钟和秒，值以'HH:MM:SS'或HHMMSS格式化，取决于函数是在一个字符串还是在数字 <br />上下文中被使用。&nbsp;&nbsp;<br />mysql&gt; select SEC_TO_TIME(2378);&nbsp;&nbsp;<br />-&gt; '00:39:38'&nbsp;&nbsp;<br />mysql&gt; select SEC_TO_TIME(2378) + 0;&nbsp;&nbsp;<br />-&gt; 3938&nbsp;&nbsp;<br />TIME_TO_SEC(time)&nbsp;&nbsp;<br />返回time参数，转换成秒。&nbsp;&nbsp;<br />mysql&gt; select TIME_TO_SEC('22:23:00');&nbsp;&nbsp;<br />-&gt; 80580&nbsp;&nbsp;<br />mysql&gt; select TIME_TO_SEC('00:39:38');&nbsp;&nbsp;<br />-&gt; 2378</div>]]></description>
		</item>
		    
		
		<item>
			<title>java-flash </title>
			<link>http://wanglch200.blog.sohu.com/36094690.html</link>
			<comments>http://wanglch200.blog.sohu.com/36094690.html#comment</comments>
			<dc:creator>幽灵特工</dc:creator>
			<pubDate>Sat, 3 Mar 2007 13:40:46 +0800</pubDate>
			<guid>http://wanglch200.blog.sohu.com/36094690.html</guid>
			<description><![CDATA[<p>import java.awt.event.*;<br />import java.util.*;<br />import java.awt.*;<br />import java.io.*;<br />import java.net.*;</p>
<p>/**<br />&nbsp;*<br />&nbsp;* CommServer<br />&nbsp;* &lt;BR&gt;&lt;BR&gt;<br />&nbsp;* Generic Flash Communication Server.&nbsp; All communications sent and received<br />&nbsp;* are (must be) terminated with a null character ('\0') consistent with<br />&nbsp;* the way Flash does socket communications.&nbsp; Any client which uses this<br />&nbsp;* protocol should also work.<br />&nbsp;* &lt;BR&gt;&lt;BR&gt;<br />&nbsp;* The server accepts messages from connected clients and broadcasts (verbatim)<br />&nbsp;* those messages to all connected clients.&nbsp; When clients connect or disconnect<br />&nbsp;* the server also broadcasts the number of clients via a NUMCLIENTS tag.<br />&nbsp;*<br />&nbsp;* Usage: java CommServer [port]<br />&nbsp;*<br />&nbsp;* @author&nbsp; Derek Clayton&nbsp;&nbsp; derek_clayton@iceinc.com<br />&nbsp;* @version 1.0.1<br />&nbsp;*/</p>
<p>public class CommServer {<br />&nbsp;&nbsp;&nbsp; private Vector clients = new Vector();&nbsp; // a list of all connected clients<br />&nbsp;&nbsp;&nbsp; ServerSocket server;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // the server<br />&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; /**<br />&nbsp;&nbsp;&nbsp;&nbsp; * Constructor for the CommServer.&nbsp; Begins the start server process.<br />&nbsp;&nbsp;&nbsp;&nbsp; * @param&nbsp;&nbsp; port&nbsp;&nbsp; Port number the server should listen to for connections.<br />&nbsp;&nbsp;&nbsp; */<br />&nbsp;&nbsp;&nbsp; public CommServer(int port) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; startServer(port);<br />&nbsp;&nbsp;&nbsp; }</p>
<p>&nbsp;&nbsp;&nbsp; /**<br />&nbsp;&nbsp;&nbsp;&nbsp; * Starts the server and listens for connections.<br />&nbsp;&nbsp;&nbsp;&nbsp; * @param&nbsp;&nbsp; port&nbsp;&nbsp; Port number the server should listen to for connections.<br />&nbsp;&nbsp;&nbsp; */<br />&nbsp;&nbsp;&nbsp; private void startServer(int port) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; writeActivity(&quot;Attempting to Start Server&quot;);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // --- create a new server <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; server = new ServerSocket(port);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; writeActivity(&quot;Server Started on Port: &quot; + port);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // --- while the server is active...<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while(true) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // --- ...listen for new client connections<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Socket socket = server.accept();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CSClient client = new CSClient(this, socket);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; writeActivity(client.getIP() + &quot; connected to the server.&quot;);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // --- add the new client to our client list <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; clients.addElement(client);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // --- start the client thread<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; client.start();&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // --- broadcast the new number of clients<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; broadcastMessage(&quot;&lt;NUMCLIENTS&gt;&quot; + clients.size()<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; + &quot;&lt;/NUMCLIENTS&gt;&quot;);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } catch(IOException ioe) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; writeActivity(&quot;Server Error...Stopping Server&quot;);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // kill this server<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; killServer();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <br />&nbsp;&nbsp;&nbsp; }</p>
<p>&nbsp;&nbsp;&nbsp; /**<br />&nbsp;&nbsp;&nbsp;&nbsp; * Broadcasts a message too all connected clients.&nbsp; Messages are terminated<br />&nbsp;&nbsp;&nbsp;&nbsp; * with a null character.<br />&nbsp;&nbsp;&nbsp;&nbsp; * @param&nbsp;&nbsp; message&nbsp;&nbsp;&nbsp; The message to broadcast.<br />&nbsp;&nbsp;&nbsp; */<br />&nbsp;&nbsp;&nbsp; public synchronized void broadcastMessage(String message) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // --- add the null character to the message<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; message += '\0';<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // --- enumerate through the clients and send each the message<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Enumeration enum = clients.elements();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while (enum.hasMoreElements()) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CSClient client = (CSClient)enum.nextElement();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; client.send(message);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; }</p>
<p>&nbsp;&nbsp;&nbsp; /**<br />&nbsp;&nbsp;&nbsp;&nbsp; * Removes clients from the client list.<br />&nbsp;&nbsp;&nbsp;&nbsp; * @param&nbsp;&nbsp; client&nbsp;&nbsp;&nbsp; The CSClient to remove.<br />&nbsp;&nbsp;&nbsp; */<br />&nbsp;&nbsp;&nbsp; public void removeClient(CSClient client) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; writeActivity(client.getIP() + &quot; has left the server.&quot;);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // --- remove the client from the list<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; clients.removeElement(client);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // --- broadcast the new number of clients<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; broadcastMessage(&quot;&lt;NUMCLIENTS&gt;&quot; + clients.size() + &quot;&lt;/NUMCLIENTS&gt;&quot;);<br />&nbsp;&nbsp;&nbsp; }</p>
<p>&nbsp;&nbsp;&nbsp; /**<br />&nbsp;&nbsp;&nbsp;&nbsp; * Writes a message to System.out.println in the format<br />&nbsp;&nbsp;&nbsp;&nbsp; * [mm/dd/yy hh:mm:ss] message.<br />&nbsp;&nbsp;&nbsp;&nbsp; * @param&nbsp;&nbsp; activity&nbsp;&nbsp;&nbsp; The message.<br />&nbsp;&nbsp;&nbsp; */<br />&nbsp;&nbsp;&nbsp; public void writeActivity(String activity) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // --- get the current date and time<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Calendar cal = Calendar.getInstance();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; activity = &quot;[&quot; + cal.get(Calendar.MONTH) <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; + &quot;/&quot; + cal.get(Calendar.DAY_OF_MONTH) <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; + &quot;/&quot; + cal.get(Calendar.YEAR) <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; + &quot; &quot; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; + cal.get(Calendar.HOUR_OF_DAY) <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; + &quot;:&quot; + cal.get(Calendar.MINUTE) <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; + &quot;:&quot; + cal.get(Calendar.SECOND) <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; + &quot;] &quot; + activity + &quot;\n&quot;;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // --- display the activity<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out.print(activity);<br />&nbsp;&nbsp;&nbsp; }</p>
<p>&nbsp;&nbsp;&nbsp; /**<br />&nbsp;&nbsp;&nbsp;&nbsp; * Stops the server.<br />&nbsp;&nbsp;&nbsp; */<br />&nbsp;&nbsp;&nbsp; private void killServer() {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // --- stop the server<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; server.close();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; writeActivity(&quot;Server Stopped&quot;);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } catch (IOException ioe) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; writeActivity(&quot;Error while stopping Server&quot;);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; public static void main(String args[]) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // --- if correct number of arguments<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(args.length == 1) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } else {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // otherwise give correct usage<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out.println(&quot;Usage: java CommServer [port]&quot;);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CommServer myCS = new CommServer(3000);<br />&nbsp;&nbsp;&nbsp; }<br />}</p>
<p>&nbsp;</p>
<p>//==================================================================</p>
<p>// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-<br />// moock chat client<br />// version 1.0.1<br />//<br />// java server by derek clayton<br />// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-</p>
<p>// *** general init<br />var incomingUpdated = false;&nbsp;// trace whether or not we need to scroll to the end of the incoming window<br />incoming = &quot;&quot;;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// clear the HTML text field so it doesn't start with a blank &lt;P&gt; tag</p>
<p>// attach the scroll manager movie (see its child movie's enterframe event for scroll code)<br />// note that we only need the scroll manager because of text field bugs in r30 of the flash 5 player<br />attachMovie(&quot;processScroll&quot;, &quot;processScroll&quot;, 0);</p>
<p>var click = new Sound();&nbsp;&nbsp;// sound to play when user receives a message<br />click.attachSound(&quot;click&quot;);</p>
<p>var welcomeSound = new Sound();&nbsp;// sound to play when user joins or leaves<br />welcomeSound.attachSound(&quot;welcome&quot;);</p>
<p>// turn off ugly yellow highlight on buttons<br />_focusrect = 0;</p>
<p>// *** creates a new socket and attempts to connect to the server<br />function connect () {<br />&nbsp;mySocket = new XMLSocket();<br />&nbsp;mySocket.onConnect = handleConnect;<br />&nbsp;mySocket.onClose = handleClose;<br />&nbsp;mySocket.onXML = handleIncoming;<br />&nbsp;&nbsp;&nbsp; // specify your server and port number here<br />&nbsp;if (!mySocket.connect(&quot;localhost&quot;, 3000)) gotoAndStop(&quot;connectionFailed&quot;);<br />&nbsp;mySocket.host = host;<br />&nbsp;mySocket.port = port;<br />}</p>
<p>// *** event handler to respond to the completion of a connection attempt<br />function handleConnect (succeeded) {<br />&nbsp;if(succeeded) {<br />&nbsp;&nbsp;mySocket.connected = true;<br />&nbsp;&nbsp;gotoAndStop(&quot;chat&quot;);<br />&nbsp;&nbsp;Selection.setFocus(&quot;_level0.outgoing&quot;);<br />&nbsp;} else {<br />&nbsp;&nbsp;gotoAndStop(&quot;connectionFailed&quot;);<br />&nbsp;&nbsp;trace(&quot;connection failed&quot;);<br />&nbsp;}<br />}</p>
<p>// *** event handler called when server kills the connection<br />function handleClose () {<br />&nbsp;incoming += (&quot;the server at &quot; + mySocket.host + &quot; has terminated the connection.\n&quot;);<br />&nbsp;incomingUpdated = true;<br />&nbsp;mySocket.connected = false;<br />&nbsp;numClients = 0;<br />}</p>
<p>// *** event handler to receive and display incoming messages<br />function handleIncoming (messageObj) {<br />&nbsp;<br />&nbsp;// display the received xml data in the output window<br />&nbsp;trace(&quot;--------new data received-----------&quot;);<br />&nbsp;trace(&quot;&gt;&gt;&quot; + messageObj.toString() + &quot;&lt;&lt;&quot;);<br />&nbsp;trace(&quot;-------- end of new data -----------&quot;);</p>
<p>&nbsp;// tell the text field manager it's time to scroll<br />&nbsp;incomingUpdated = true;<br />&nbsp;lastScrollPos = incoming.scroll;</p>
<p>&nbsp;// check the time<br />&nbsp;var now = new Date();<br />&nbsp;var hours = now.getHours();<br />&nbsp;var minutes = now.getMinutes();<br />&nbsp;var seconds = now.getSeconds();<br />&nbsp;hours = (hours &lt; 10 ? &quot;0&quot; : &quot;&quot;) + hours;<br />&nbsp;minutes = (minutes &lt; 10 ? &quot;0&quot; : &quot;&quot;) + minutes;<br />&nbsp;seconds = (seconds &lt; 10 ? &quot;0&quot; : &quot;&quot;) + seconds;</p>
<p>&nbsp;// the server sends NUMCLIENTS any time a client connects or disconnects.<br />&nbsp;// if we find NUMCLIENTS in the xml object...<br />&nbsp;if (messageObj.firstChild.nodeName == &quot;NUMCLIENTS&quot;) {<br />&nbsp;&nbsp;// ...then check if the incoming messages window is empty. if it is...<br />&nbsp;&nbsp;if(incoming == &quot;&quot;) {<br />&nbsp;&nbsp;&nbsp;// ...then the user is new, so welcome them<br />&nbsp;&nbsp;&nbsp;incoming += (&quot;&lt;FONT COLOR='#507373'&gt;&lt;B&gt;welcome to moock comm 1.0.1, &quot;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;+ convertTags(userID) + &quot;\n&quot;<br />&nbsp;&nbsp;&nbsp;&nbsp;+ &quot;&nbsp;&nbsp; Connection time:&lt;/B&gt; &quot; + hours + &quot;:&quot; + minutes + &quot;:&quot; + seconds + &quot;\n&quot;<br />&nbsp;&nbsp;&nbsp;&nbsp;+ &quot;&lt;B&gt;&nbsp;&nbsp; server:&lt;/B&gt; 京华时报 Flash XmlSocket Chat Server&lt;/FONT&gt;\n\n&quot;);<br />&nbsp;&nbsp;} else {<br />&nbsp;&nbsp;&nbsp;// otherwise, someone has arrived or departed, so tell the user<br />&nbsp;&nbsp;&nbsp;if(parseInt(messageObj.firstChild.firstChild.nodeValue) &gt; numClients) {<br />&nbsp;&nbsp;&nbsp;&nbsp;// report the client arrival in the chat window<br />&nbsp;&nbsp;&nbsp;&nbsp;incoming += (&quot;&lt;FONT COLOR='#507373'&gt;&lt;B&gt;&quot; + hours + &quot;:&quot; + minutes + &quot;:&quot; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; + seconds + &quot; a new user has connected.&quot;&nbsp; + &quot;&lt;/B&gt;&lt;/FONT&gt;\n&quot;);<br />&nbsp;&nbsp;&nbsp;&nbsp;} else {<br />&nbsp;&nbsp;&nbsp;&nbsp;// report the client departure in the chat window<br />&nbsp;&nbsp;&nbsp;&nbsp;incoming += (&quot;&lt;FONT COLOR='#507373'&gt;&lt;B&gt;&quot; + hours + &quot;:&quot; + minutes + &quot;:&quot; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; + seconds + &quot; a user disconnected.&quot;&nbsp; + &quot;&lt;/B&gt;&lt;/FONT&gt;\n&quot;);&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;}<br />&nbsp;&nbsp;// finally, keep track of the number of clients and play a welcome sound<br />&nbsp;&nbsp;numClients = messageObj.firstChild.firstChild.nodeValue;<br />&nbsp;&nbsp;welcomeSound.setVolume(100);<br />&nbsp;&nbsp;welcomeSound.start();<br />&nbsp;} else {<br />&nbsp;&nbsp;// no NUMCLIENTS node was found, so this is just a regular message.<br />&nbsp;&nbsp;// grab the user name and message from our xml object<br />&nbsp;&nbsp;var user = messageObj.firstChild.firstChild.nodeValue;<br />&nbsp;&nbsp;var message = messageObj.childNodes[1].firstChild.nodeValue;</p>
<p>&nbsp;&nbsp;// add the message to the chat window, with a time stamp<br />&nbsp;&nbsp;incoming += (hours + &quot;:&quot; + minutes + &quot;:&quot;<br />&nbsp;&nbsp;&nbsp;&nbsp;+ seconds + &quot;&lt;B&gt;&quot; + unescape(user) + &quot;&lt;/B&gt;&amp;gt;&amp;gt; &quot; + addLinks(unescape(message)) + &quot;\n&quot;);</p>
<p>&nbsp;&nbsp;// now do the new message click. if it's been more than 30 secs since the last message,<br />&nbsp;&nbsp;// sound a loud click. otherwise sound a quiet click<br />&nbsp;&nbsp;trace(&quot;time since last message: &quot; + (now - lastIncomingMessageTime));<br />&nbsp;&nbsp;if (lastIncomingMessageTime &amp;&amp; now - lastIncomingMessageTime &gt; 30000) {<br />&nbsp;&nbsp;&nbsp;click.setVolume(200);<br />&nbsp;&nbsp;} else {<br />&nbsp;&nbsp;&nbsp;click.setVolume(30);<br />&nbsp;&nbsp;}<br />&nbsp;&nbsp;click.start();<br />&nbsp;&nbsp;}</p>
<p>&nbsp;// truncate the contents of the incoming messages window if it's longer than 5000 characters<br />&nbsp;if(incoming.length &gt; 5000) {<br />&nbsp;&nbsp;var nearestNewline = incoming.indexOf(&quot;\n&quot;, incoming.length - 5000);<br />&nbsp;&nbsp;incoming = incoming.substring(nearestNewline, incoming.length);<br />&nbsp;}</p>
<p>&nbsp;// remember when this message arrived for next time<br />&nbsp;lastIncomingMessageTime = now;<br />}</p>
<p>// *** sends a new xml object to the server<br />function sendMessage() {<br />&nbsp;// create the message to send as an xml source fragment. we're sending html so we<br />&nbsp;// have to escape our text and change &lt; and &gt; to entities via convertTags<br />&nbsp;var message = '&lt;USER&gt;%20' + escape(convertTags(userID)) + '&lt;/USER&gt;&lt;MESSAGE&gt;' <br />&nbsp;&nbsp;+ escape(convertTags(outgoing)) + '%20&lt;/MESSAGE&gt;';&nbsp;// note that the forced spaces (%20) are required so<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// MESSAGE and USER always have a text child node<br />&nbsp;<br />&nbsp;// convert the message into an xml object hierarchy<br />&nbsp;messageObj = new XML();<br />&nbsp;messageObj.parseXML(message);</p>
<p>&nbsp;// check what we're sending<br />&nbsp;trace(&quot;Sending: &quot; + messageObj);</p>
<p>&nbsp;// if a socket object has been created and is connected, send the xml message<br />&nbsp;// otherwise warn the user that they need to connect<br />&nbsp;if (mySocket &amp;&amp; mySocket.connected) {<br />&nbsp;&nbsp;mySocket.send(messageObj);<br />&nbsp;&nbsp;outgoing = &quot;&quot;;<br />&nbsp;} else {<br />&nbsp;&nbsp;// the server must have kicked us off...<br />&nbsp;&nbsp;incoming += &quot;&lt;FONT COLOR='#507373'&gt;&lt;B&gt;you are no longer connected. please reconnect.&quot;<br />&nbsp;&nbsp;&nbsp;+ &quot;&lt;/B&gt;&lt;/FONT&gt;\n&quot;;<br />&nbsp;&nbsp;incomingUpdated = true;<br />&nbsp;}<br />}</p>
<p>// *** closes the connection to the server<br />function quit() {<br />&nbsp;if (mySocket.connected) {<br />&nbsp;&nbsp;mySocket.close();<br />&nbsp;&nbsp;mySocket.connected = false;<br />&nbsp;&nbsp;numClients = 0;<br />&nbsp;&nbsp;incoming = &quot;&quot;;<br />&nbsp;&nbsp;gotoAndStop(&quot;login&quot;);<br />&nbsp;}<br />}</p>
<p><br />// *** changes &lt; and &gt; to &amp;lt; and &amp;gt;<br />function convertTags(theString) {<br />&nbsp;var tempString = &quot;&quot;;<br />&nbsp;for(var i = 0; i &lt; theString.length; i++) {<br />&nbsp;&nbsp;if(theString.charAt(i) == &quot;&lt;&quot;) {<br />&nbsp;&nbsp;&nbsp;tempString += &quot;&amp;lt;&quot;;<br />&nbsp;&nbsp;} else if (theString.charAt(i) == &quot;&gt;&quot;) {<br />&nbsp;&nbsp;&nbsp;tempString += &quot;&amp;gt;&quot;;<br />&nbsp;&nbsp;} else {<br />&nbsp;&nbsp;&nbsp;tempString += theString.charAt(i);<br />&nbsp;&nbsp;}<br />&nbsp;}<br />&nbsp;trace(&quot;tempString: &quot; + tempString);<br />&nbsp;return tempString;<br />}</p>
<p>// *** inserts &lt;A&gt; tags into a string anywhere a &quot;www&quot; occurs<br />function addLinks (theString) {<br />&nbsp;var startIndex = 0;<br />&nbsp;var tempString = &quot;&quot;;<br />&nbsp;var linkString;<br />&nbsp;var URL;<br />&nbsp;var beginURL;<br />&nbsp;var endURL;<br />&nbsp;if(theString.indexOf(&quot;www&quot;) != -1) {<br />&nbsp;&nbsp;while(theString.indexOf(&quot;www&quot;, startIndex) != -1) {<br />&nbsp;&nbsp;&nbsp;tempString += theString.substring(startIndex, theString.indexOf(&quot;www&quot;, startIndex));<br />&nbsp;&nbsp;&nbsp;beginURL = theString.indexOf(&quot;www&quot;, startIndex);<br />&nbsp;&nbsp;&nbsp;endURL = (theString.indexOf(&quot; &quot;, beginURL) != -1) ? theString.indexOf(&quot; &quot;, beginURL) : theString.length;<br />&nbsp;&nbsp;&nbsp;URL = theString.substring(beginURL, endURL);<br />&nbsp;&nbsp;&nbsp;linkString = &quot;&lt;A HREF='http://&quot; + URL + &quot;' TARGET='_blank'&gt;&lt;U&gt;&lt;FONT COLOR='#FFFFCC'&gt;&quot; + URL + &quot;&lt;/FONT&gt;&lt;/U&gt;&lt;/A&gt;&quot;;&nbsp;<br />&nbsp;&nbsp;&nbsp;tempString += linkString;<br />&nbsp;&nbsp;&nbsp;startIndex = endURL;<br />&nbsp;&nbsp;}<br />&nbsp;&nbsp;tempString += theString.substring(endURL, theString.length);<br />&nbsp;&nbsp;return tempString;<br />&nbsp;} else {<br />&nbsp;&nbsp;return theString;<br />&nbsp;}<br />}</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><br />&nbsp;</p>
<p>&nbsp;</p>
<p><br />&nbsp;</p>]]></description>
		</item>
		    
		
		<item>
			<title>暗暗报到了</title>
			<link>http://wanglch200.blog.sohu.com/36093556.html</link>
			<comments>http://wanglch200.blog.sohu.com/36093556.html#comment</comments>
			<dc:creator>幽灵特工</dc:creator>
			<pubDate>Sat, 3 Mar 2007 13:34:56 +0800</pubDate>
			<guid>http://wanglch200.blog.sohu.com/36093556.html</guid>
			<description><![CDATA[<p>亲爱的朋友们,我也要好好维护自己的东西了</p>
<p>在此我将用我的想法描述我自己的也是大家的一幅画,一个想法.</p>]]></description>
		</item>
		    
		
	</channel>
</rss>
