星期五, 四月 30, 2004

UTR#17: Character Encoding Model/要了解Java 最新的Unicode支持问题,必须了解的ABC.

UTR#17: Character Encoding Model: "Character Encoding Model"

Java Platform补充字符(supplementary characters)在j2se 1.5

Java 使用固定宽度的16bit的来表示char字符,所以Java可以处理多达65536个字符.
但是Unicode 现在可以支持1,112,064个字符.
中国现在支持gb18030,台湾支持:CNS-11643字符.
有关J2SE 1.5如何支持这些字符参看http://java.sun.com/developer/technicalArticles/Intl/Supplementary/

Support for supplementary characters is likely to also become a common business requirement in East Asian markets. Government applications are going to require them in order to correctly represent names that include rare Chinese characters. Publishing applications may need them in order to represent the full set of historical and variant characters. The Chinese government requires support for GB18030, a character encoding that encodes the entire Unicode character set, and so includes supplementary characters if Unicode version 3.1 or later is assumed. The Taiwanese standard CNS-11643 includes numerous characters that have been included in Unicode 3.1 as supplementary characters. The Hong Kong government defined a collection of characters that are needed for Cantonese, and some of these characters are supplementary characters in Unicode. Finally, some vendors in Japan are planning to use the large private use area in the supplementary character space for more than 50,000 kanji character variants in order to migrate from their proprietary systems to solutions based on the Java platform.

如何用Javascript判断上传文件的大小及是否图片.小窍门.

代码使用与IE 6.FireFox需要修改关于层的访问代码.

<html>
<head>
<title>
UploadFile
</title>
<script>
isimage=false;
function displayimg()
{
isimage=false;//判断文件是否图片的标志
var tmpstr=document.mainform.name.value;
if(tmpstr!=null || tmpstr!='')
document.all.contentLayer.document.user.src=tmpstr;
if(isimage==false)alert("文件不是图片");
}
function checksize()
{
isimage=true; //如果文件不是图片,onload的时候就不会调用这个函数
var limitsize=3072;
/*
if (dumy.fileSize>limitsize)
{
mainform.reset();
alert("fileSize should be less than "+limitsize + " bytes");
}
alert("width"+dumy.width+" height"+dumy.height);
*/
}

</script>
</head>
<body bgcolor>
上传:<strong><font size=+1></h1></font></strong>的照片
<FORM name="mainform" action='' ENCTYPE='multipart/form-data' method='POST' >
<INPUT TYPE='file' NAME='name' size="40" maxlength="255" onchange="displayimg();">
<INPUT TYPE='submit' VALUE='start...' >
</FORM>
<hr>
<div id="contentLayer">
Preview:<img id ="dumy" name=user src="../IMAGES/image1/person.GIF" onload="checksize();">
</div>

</body>
</html>


星期三, 四月 28, 2004

TheServerSide.com - TSS Featured Entry

TheServerSide.com - TSS Featured Entry

这里有些经验非常好.paste过来.留着
To get JVM Metrics, i.e. Heap/Garbage Collection stats, add the following to your java command:
-verbose:gc -XX:+PrintGCTimeStamps
The default JVM heap size is 64MB, which is likely too small for most webapps. You can change the default min/max by adding the following to your JAVA_OPTS (or CATALINA_OPTS) environment variable:
-Xms128m -Xmx256m
Young generation sizing - let the JVM do it by specifying:
-XX:+AggressiveHeap
Connection Pool Size: 15-20 is more than enough to handle an average application. Never have more connections than threads that can use them. For MySQL, the pool size is resource throttling, not saving connection setup time. Click here for a chart that shows the number of connections used doesn't change between a pool size of 10 and 20.
Connection/J 3.0 is 40-400% faster than 2.0.14 depending on the situation - use the latest driver!
Finally, here is the really good stuff. Below are a number of parameters you can add to your JDBC URL (like autoReconnect=true) to get information from MySQL's JDBC Driver:

Logging Slow Queries: logSlowQueries=true and slowQueryThresholdMillis=n (2000 default)
Reporting Performance Metrics: gatherPerfMetrics=true and reportMetricsIntervalMillis=n (30s default)
Usage Advisor (abandoned objects, un-used columns in selects, incomplete ResultSet traversal): useUsageAdvisor=true

星期二, 四月 27, 2004

JDBC Rowset 1.0终于到了FCS阶段了。

使用了以下,很好,preview 2中发现的两个bug都修正了。尤其是愚蠢的Thread.currentTread().getSystemClassLoader()错误。

干的好。
非常漂亮。

星期一, 四月 26, 2004

设计系统评价标准.一

strong>Capabilities Capabilities = Non-Functional System Requirements
? Availability: service is accessible
? Reliability: consistency of application and transactions
? Capacity: can serve # users
? Extensibility: can add functionality
? Flexibility: can support changes
? Performance: good response time
? Scalability: can support increased load

能力=非功能性的系统要求
可用性:服务容易接受的
可靠性:保持一致的应用和事务
生产量:可以同时服务的用户
可扩展性:可以添加功能
灵活性:可以支持变化
性能:良好的反应时间
可测量性:可支持增加的负载

星期五, 四月 23, 2004

java.net: Generating Images with JSPs and Servlets [Apr. 22, 2004]

java.net: Generating Images with JSPs and Servlets [Apr. 22, 2004]
用Java 2D/3D/SWING,哈,来产生图象.
非常爽啊.

-----
今天,申请到了Gmail.com Email Account,

星期二, 四月 20, 2004

JSP/JSTL include.


<jsp:param> 汉字编码,使用java.net.URLEncoder.encode(string,string) encode.

星期五, 四月 16, 2004

开发多语言版本应用JSTLDeveloping Multilingual Web Applications Using JavaServer Pages Technology

Developing Multilingual Web Applications Using JavaServer Pages



重点:这里介绍了一个非常重要的技巧,就是JSTL的在Servlet 2.4之前的一个不足或者说实话Servlet 2.3的不足,
就是在调用的时候会覆盖JSP页面的contentType和pageEncoding指定的语言.
在Servlet 2.4或JSP 2.0已经解决了这个问题.但是在Servlet 2.3(Tomecat 4.x)如何搞定呢?
本文提供了一个技巧,在之前调用<%response.flushBuffer();%>来冻结整个JSP的web page 的Encoding,防止暗地里改变了Encoding.主要原因,本文详细解释了.


Netbeans 3.6 完美支持I18n 字典资源文件输入功能.

类似于VB,VC中的多语言字典输入界面.

星期五, 四月 09, 2004

JDO Vendor 资源一缆表

TJDO Project Page
据说是是根据Sun RI扩展了支持各种DB,只能用于研究,是免费的.


OJB - ObJectRelationalBridge
Apache实现的面向对象数据库的API,不过JDO规范的实现不全面.

http://castor.exolab.org/jdo.html
最佳开源完全功能JDO规范API

http://jcredo.com/
一个商业的JDO提供商.
众多其他商业提供商,可以在www.jdocentral.com resource下看到.


如何使用Sun 公司JDO 1.0.1 Enhancer. JDO使用笔记之一

Sun 公司JDO1.0.1(JDO Offical Home),发布了实现包Implenment.在使用其增强class的时候经常碰到一些问题.主要问题依然是ClassLoader搜索CLASSPATH引起的问题,在具有多级包层次结构的时候,常出现NullPointerException问题.只要设置对了CLASSPATH就可以解决问题.
为了方便编译及Enhancer class,需要简单编制两个批命令文件.
1.jdoc.bat(jdoc.sh),用来增强(Enhancer)Class
2.jod.bat(jdo.sh),用来运行client.

jdoc.bat

@echo off
setlocal
REM JDO_HOME是下载的Sun公司Enhancer实现包展开后的目录.
echo JDO Enhancer Batch file

SET JDO_HOME=C:\William_wang\JDO\jdo-1_0_1-ri
REM 设置了CLASSPATH=.,或设置为包层次的定级目录
set CLASSPATH=%CLASSPATH%;.;%JDO_HOME%\jdo.jar;%JDO_HOME%\jdori.jar;%JDO_HOME%\jdori-enhancer.jar;%JDO_HOME%\btree.jar
@echo on

java com.sun.jdori.enhancer.Main %1 %2 %3 %4 %5 %6 %7 %8 %9

@echo off
endlocal

jdo.bat
@echo off
setlocal

SET JDO_HOME=C:\William_wang\JDO\jdo-1_0_1-ri

set CLASSPATH=%CLASSPATH%;.;%JDO_HOME%\jdo.jar;%JDO_HOME%\jdori.jar;%JDO_HOME%\jdori-enhancer.jar;%JDO_HOME%\btree.jar
@echo on

java %1 %2 %3 %4 %5 %6 %7 %8 %9

@echo off
endlocal

标准的Class是一般的JavaBean写法.或POJO类或VO类写法一致,属性及Seter/Geter方法


J2SE 1.6 将成为一个OS?

J2SE 1.6计划加入多任务共享ByteCode代码的特征.这讲是JVM具有了OS级别的特点.如果实现了这个功能,JVM将作为系统的一个服务而存在了.
另外J2SE 1.6计划加入Socket Direct Protocol(SDP).
详细的内容参考http://infiniband.sourceforge.net/NW/SDP/overview.htm

星期四, 四月 08, 2004

星期三, 四月 07, 2004

JSTL1.0 明显对象列表.

ExpressionMapping
$foopageContext.findAttribute("foo")
$param:foorequest.getParameter("foo")
$header:foo request.getHeader("foo")
$cookie:foo maps to the cookie's value for name foo
$initParam:fooapplication.getInitParameter("foo")
$pageScope:foopageContext.getAttribute( "foo", PageContext.PAGE_SCOPE)
$requestScope:foo pageContext.getAttribute( "foo", PageContext.REQUEST_SCOPE)
$sessionScope:foo pageContext.getAttribute( "foo", PageContext.SESSION_SCOPE)
$applicationScope:foopageContext.getAttribute( "foo", PageContext.APPLICATION_SCOPE)

星期二, 四月 06, 2004

Jboss 3.2.x 序列数据库CA配置

在deploy目录下的:jboss-jca.sar 中的 stylesheet/jboss-ds_1_0.dtd
里面包含了Jboss 3.2.x的配置关键元素词:
有关Transaction-isolation 级别的选择如下:
<transaction-isolation>TRANSACTION_SERIALIZABLE</transaction-isoation>
包含的合法选项为:
TRANSACTION_READ_UNCOMMITTED
TRANSACTION_READ_COMMITTED
TRANSACTION_REPEATABLE_READ
TRANSACTION_SERIALIZABLE
TRANSACTION_NONE

Oracle vs. MySQL Transaction Isolation

Oracle vs. MySQL Transaction Isolation



Most (all) database management systems allow you to have control over the isolation level of your transactions. However, the database's behavior at each isolation level is, unfortunately, vendor-specific. Also, every vendor does not support all transaction isolation levels. Here I compare the transaction isolation behavior of Oracle to that of MySQL.


As a reminder, there are four standard transaction isolation levels:


Transaction Isolation Levels

Isolation LevelDirty readUnrepeatable readPhantom read
Read UncommittedYesYesYes
Read CommittedNoYesYes
Repeatable ReadNoNoYes
SerializableNoNoNo

According to the table, the Serializable isolation level prevents dirty reads, unrepeatable reads, and phantom reads. The Read Uncommitted isolation level allows all three concurrency hazards.


Here's a summary of these concurrency hazards:


Dirty Read: Occurs when the intermediate (uncommitted) results of one transaction are made visible to another transaction.
Unrepeatable Read: Occurs when one transaction reads a data item and subsequently rereads the same item and sees a different value.
Phantom Read: Occurs when one transaction performs a query that returns multiple rows, and later executes the same query again and sees additional rows that were not present the first time the query was executed.
Now let's compare the behaviors of Oracle and MySQL with respect to transaction isolation.
Here are some helpful hints on how to experiment with transaction isolation levels in the client programs of Oracle and MySQL.
Controlling transaction isolation behavior with the database's client program

Transaction InfoOracleMySQL
Client programsqlplusmysql
Default isolation levelRead CommittedRepeatable Read
How to manually set the isolation levelSET TRANSACTION ISOLATION LEVEL {READ COMMITTED | SERIALIZABLE}SET TRANSACTION ISOLATION LEVEL {READ UNCOMMITTED | READ COMMITTED | REPEATABLE READ | SERIALIZABLE}
How to query the isolation levelNot supported?SELECT @@tx_isolation
How to start a transactionautocommit is off by default, so a new transaction is started after each COMMIT or ROLLBACKSTART TRANSACTION
How to end a transactionCOMMIT or ROLLBACKCOMMIT or ROLLBACK
How to control the default transaction isolation levelRely on app server-specific deployment descriptor? (Weblogic supports specifying the isolation level, JBoss does not.)Put a line like the following in the [mysqld] section of my.cnf:

tranaction-isolation = REPEATABLE-READ
Of course, in a real J2EE application, you wouldn't explicitly run these commands. The database/application server would take care of this for you.
Transaction isolation behavior differences
The following statement is true for both Oracle and MySQL:
For all transaction isolation levels, if one transaction performs an update on a row, all other transactions are blocked if they attempt to update that same row, until the first transaction ends.

Isolation LevelOracleMySQL
Read UncommittedNot supportedThe intermediate (uncommitted) results of one transaction are made visible to all other transactions.
Read CommittedWhen one transaction commits, those changes are immediately visible in all other currently running transactions.When one transaction commits, those changes are immediately visible in all other currently running transactions.
Repeatable ReadNot supportedThe first time that a read is performed on a table results in that view of the table being preserved throughout that transaction. Any changes made on that table committed by other transactions after that point are not seen. However, if a different transaction commits a change between the time that you start your transaction and the time that you perform your first read on that table, you will see the changes made by that other transaction.

Phantom reads are prevented, even though officially phantom reads are supposed to be allowed at this isolation level.
SerializablePhantom reads are prevented, but transactions are not blocked on reads like in MySQL.If one transaction performs an update on a row, all other transactions are blocked if they attempt to update or even read that row, until the first transaction ends. Thus phantom reads are prevented.