lqxue

常用链接

统计

book

tools

最新评论

#

PreparedStatement

表示预编译的 SQL 语句的对象。 SQL 语句被预编译并且存储在
<CODE>PreparedStatement</CODE> 对象中。然后可以使用此对象高效地多次执行该语句</P>

posted @ 2007-07-02 15:52 lqx 阅读(219) | 评论 (0)编辑 收藏

[收藏]xml和html有什么区别?

A: 关于XML和HTML区别请参考:

  “可扩展标记语言”(XML) 提供一种描述结构化数据的方法。与主要用于控制数据的显示和外观的 HTML 标记不同,XML 标记用于定义数据本身的结构和数据类型。

  XML 使用一组标记来描绘数据元素。每个元素封装可能十分简单也可能十分复杂的数据。您可以定义一组无限制的 XML 标记。例如,您可以定义一些 XML 标记来声明订单中的数据,如价格、税收、发货地址、帐单地址等等。由于 XML 标记在整个单位中以及跨单位采用,因此来自各种不同数据存储区的数据将更容易交换和操作。

  XML 是一种简单、与平台无关并被广泛采用的标准。XML 相对于 HTML 的优点是它将用户界面与结构化数据分隔开来。这种数据与显示的分离使得集成来自不同源的数据成为可能。客户信息、订单、研究结果、帐单付款、病历、目录数据及其他信息都可以转换为 XML。

  XML 与 HTML
  以下是要记住的有关 XML 与 HTML 之间关系的几个要点:

   a.. XML 不是要替换 HTML;实际上 XML 可以视作对 HTML 的补充。XML 和 HTML 的目标不同:HTML 的设计目标是显示数据并集中于数据外观,而 XML 的设计目标是描述数据并集中于数据的内容。
   b.. 与 HTML 相似,XML 不进行任何操作。虽然 XML 标记可用于描述订单之类的项的结构,但它不包含可用于发送或处理该订单以及确保按该订单交货的任何代码。其他人必须编写代码来实际对 XML 格式的数据执行这些操作。
   c.. 与 HTML 不同,XML 标记由架构或文档的作者定义,并且是无限制的。HTML 标记则是预定义的;HTML 作者只能使用当前 HTML 标准所支持的标记。

  XML 的使用
  XML 是一种极灵活的、传递数据的方式。以下全部是可使用 XML 的场合的示例:

   a.. 普通文档
   b.. 结构化记录,如约会记录或订单
   c.. 移动数据的 Internet/Intranet Web 应用程序
   d.. 带有数据的对象,如对象或 ActiveX 控件的持久格式
   e.. 数据记录,如查询的结果集
   f.. Web 站点的元内容,如“信道定义格式”(CDF)
   g.. 图形显示,如应用程序的用户界面
   h.. Web 上信息与人的链接
   i.. C# 代码(可以用 XML 形式);有关更多信息,请参见 XML 文档
   j.. 用于定位可用 XML Web services 的发现文档;有关更多信息,请参见 XML Web services 发现。

  以下列出存储信息时 XML 相对于其他格式的若干优越性:

   a.. XML 格式是基于文本的,这使得它们更容易读、更便于记录,有时也更便于调试。
   b.. XML 文档可使用已为 HTML 建立的很多基础结构,包括 HTTP 协议和某些浏览器。HTTP 允许穿过防火墙传输 XML。
   c.. XML 分析已有完善的定义,且已广泛应用,使得在各种环境中从 XML 文档检索信息成为可能。
   d.. 应用程序可依赖 XML 分析器进行某些结构验证以及数据类型检查(当使用架构时)。
   e.. XML 建立在 Unicode 基础上,使得创建国际化文档更容易。不过,XML 并不适合于所有情况。XML 文档往往比它们替换的二进制格式详细。它们占用更多的网络带宽和存储空间,或需要更多的处理器时间进行压缩。XML 分析可能比分析高度优化的二进制格式慢,并且可能需要更多内存。然而,精心的应用程序设计能够
  避免一些问题。

  验证 XML 文档
  若要验证 XML 文档包含所需数据和结构,必须将一个 XML 架构与 XML 文档相关联。XML 架构是定义如何构造元素和属性来形成 XML 文档的规则。您可以在单位之间共享架构,以使得传输和处理共享数据变得简单。有关更多信息,请参见 XML 架构介绍。

  显示 XML 数据
  有几种方式可用于显示(或提供)XML 数据。

  还有数据绑定的机制可与样式表一起使用,以便以可视形式展示 XML 数据,以及添加交互性。

  以下是显示 XML 的几种方法:

   a.. XSLT — 可扩展样式表语言
   b.. CSS — 级联样式表
   c.. Microsoft Internet Explorer
  有关更多信息,请参见 MSDN Online XML 开发人员中心 Web 站点
  (http://msdn.microsoft.com/xml/default.asp)。

  XML 资源
  如果您熟悉 HTML,则可以学习创建 XML 文档,只要求它们有效且符合标准格式。有关
  XML 的更多信息,请参见 XML SDK 和 MSDN Online XML 开发人员中心 Web 站点
  (http://msdn.microsoft.com/xml/default.asp)。

摘自:http://www.5217.cn/Article/jzjc/wzjss/htmljs/200503/234.html

posted @ 2007-07-02 14:33 lqx 阅读(178) | 评论 (0)编辑 收藏

乐观锁和悲观锁

锁有两种:悲观锁和乐观锁。悲观锁假定其他用户企图访问或者改变你正在访问、更改的对象的概率是很高的,因此在悲观锁的环境中,在你开始改变此对象之前就将该对象锁住,并且直到你提交了所作的更改之后才释放锁。悲观的缺陷是不论是页锁还是行锁,加锁的时间可能会很长,这样可能会长时间的限制其他用户的访问,也就是说悲观锁的并发访问性不好。与悲观锁相反,乐观锁则认为其他用户企图改变你正在更改的对象的概率是很小的,因此乐观锁直到你准备提交所作的更改时才将对象锁住,当你读取以及改变该对象时并不加锁。可见乐观锁加锁的时间要比悲观锁短,乐观锁可以用较大的锁粒度获得较好的并发访问性能。但是如果第二个用户恰好在第一个用户提交更改之前读取了该对象,那么当他完成了自己的更改进行提交时,数据库就会发现该对象已经变化了,这样,第二个用户不得不重新读取该对象并作出更改。这说明在乐观锁环境中,会增加并发用户读取对象的次数。

posted @ 2007-06-29 17:25 lqx 阅读(339) | 评论 (0)编辑 收藏

difference between Synchronized method and Synchronized block

Synchronized method - By using this, the method will be thread safe. But if your method access any non-thread safe objects, you may have concurrency problem.

Synchronized block - To complement what Synchronized method cannot do. If you do:

synchronized (nonThreadSafeObject) {
// accessing nonThreadSafeObject here
}

Then the object will become thread safe.

posted @ 2007-06-29 16:50 lqx 阅读(235) | 评论 (0)编辑 收藏

Passivation and activation ?

Passivation and activation are two phases of a resource management technique that reduces the number of bean instances needed to service all clients. Passivation is the process of disassociating a bean instance from its EJB object so that the instance can be reused or evicted to conserve memory. Activation is the process of associating a bean instance with an EJB object so that it can service a request. Beans are passivated when there is a lull in their use and activated when the EJB object receives a client request.

The java.ejb.SessionBean and javax.ejb.EntityBean interface include two callback methods that notify a bean instance when it is about to passivated or activated. The ejbPassivate( ) method notifies a bean that it is about to passivated; the ejbActivate( ) method notifies a bean that it is about to activated.

The mechanisms employed in passivation and activation change depending on the bean type. Stateful beans are usually evicted, while entity beans and stateless beans are pooled. A more detailed account of how different bean types passivated and activated is found under the FAQs for that type.

posted @ 2007-06-29 16:17 lqx 阅读(135) | 评论 (0)编辑 收藏

Transaction Isolation Levels

Transaction Isolation Levels


Overview

The ANSI/ISO SQL standard defines four levels of transaction isolation in terms of three potential problems that must be prevented between concurrent transactions. These problems are:

  • Dirty Read - A transaction reads data written by another concurrent uncommitted transaction.

  • Non-Repeatable Reads - A transaction re-reads data it has previously read and finds that data has been modified by another transaction (one that has been committed since the transaction's previous read).

  • Phantom Read - A transaction re-executes a query returning a set of rows that satisfy a search condition and finds that the set of rows satisfying the condition has changed due to another recently-committed transaction.

Transaction Isolation Levels

The four levels of transaction isolation are:

  • Uncommitted Read

  • Committed Read

  • Repeatable Read

  • Serializable.

The isolation level that your transaction runs in determines how sensitive your application is to changes other users' transactions make, and consequently, how long your transaction must hold locks to protect against these changes. The ANSI SQL standard defines four levels of transaction isolation.

Uncommitted Read

Uncommitted Read, or dirty read, lets a transaction read any data currently on a data page, regardless of whether or not the data has been committed. For example, another user might have a transaction in progress that has updated data, and that transaction is holding exclusive locks on the data. Your transaction can read the data anyway, and possibly take further actions based on the values you read. The other user might then decide to roll back their transaction, so logically, those changes never occurred.

Committed Read

Committed Read ensures that an operation will never read data another application has changed but not yet committed. Because you can never read uncommitted data, if a transaction running with Committed Read isolation revisits data, that data might have changed, or new rows might appear that meet the criteria of the original query. Rows that appear in this way are called phantoms.

Repeatable Read

If you want the read operations to be repeatable, choose the third isolation level. The Repeatable Read isolation level adds to the properties of Committed Read by ensuring that if a transaction revisits data or if a query is reissued, the data will not have changed. In other words, issuing the same query twice within a transaction will not pick up any changes to data values that another user's transaction has made. No other user can modify the data that your transaction visits as long as you have not yet committed or rolled back your transaction.

Serializable

The Serializable isolation level ensures that if a query is reissued, no data will have changed and no new rows will appear in the interim. In other words, you will not see phantoms if the same query is issued twice within a transaction.

Transaction isolation Levels Behavior

The four transaction isolation levels and the corresponding behaviors are described below:

Isolation Level

Dirty Read

Non-Repeatable Read

Phantom Read

Read Uncommitted

Possible

Possible

Possible

Read Committed

Not possible

Possible

Possible

Repeatable Read

Not possible

Not possible

Possible

Serializable

Not possible

Not possible

Not possible



Support for Transaction Isolation Levels in Orbix E2A Application Server

With Orbix E2A Application Server, you can specify the transaction isolation level for an entire EJB in an application's cc.xml file by setting the new <connection-tx-isolation-level> element in the relevant <resource-ref> and <cmp-datasource> elements.

The valid values for the <connection-tx-isolation-level> element are:

  • TRANSACTION_READ_UNCOMMITTED

  • TRANSACTION_READ_COMMITTED

  • TRANSACTION_REPEATABLE_READ

  • TRANSACTION_SERIALIZABLE

The following is an extract of a cc.xml file using transaction isolation levels for the Account and Person demos that ship with Orbix E2A Application Server.

 

<configuration>
            <enterprise-beans>
            <entity>
            <ejb-name>Account</ejb-name>
            <jndi-name>iona/ipas/simple/Account</jndi-name>
            <jndi-source-name>CosNaming</jndi-source-name>
            <resource-ref>
            <res-ref-name>jdbc/Accounts</res-ref-name>
            <res-ref-link>JDBCAccounts</res-ref-link>
            <connection-tx-isolation-level>TRANSACTION_READ_COMMITTED
            </connection-tx-isolation-level>
            </resource-ref>
            </entity>
            <entity>
            <ejb-name>Person</ejb-name>
            <jndi-name>iona/ipas/simple/Person</jndi-name>
            <jndi-source-name>CosNaming</jndi-source-name>
            <cmp-datasource>
            <res-ref-name>jdbc/Person</res-ref-name>
            <res-ref-link>JDBCPerson</res-ref-link>
            <connection-tx-isolation-level>TRANSACTION_SERIALIZABLE
            </connection-tx-isolation-level>
            </cmp-datasource>
            ...
            </entity>
            </enterprise-beans>
            <resources>
            <resource>
            <resource-name>JDBCPerson</resource-name>
            <jndi-name>iona:cloudscape/demos</jndi-name>
            </resource>
            <resource>
            <resource-name>JDBCAccounts</resource-name>
            


 

     <jndi-name>iona:cloudscape/demos</jndi-name>
            </resource>
            </resources>
            ...
            </configuration>
            

 



         What are Transactions?

A transaction is unit of work containing activities that need to be completed together. For instance, for an online travel site, you might have a session bean method bookTravel that takes a credit card, ensures its valid, charges the price of the ticket on the credit card, and books the ticket. This method invoke methods on other EBJs to help accomplish these steps. For instance, methods of Customer, CreditCard and AirlineTicket beans will be invoked during the execution of this method. If all these steps complete successfully, the transaction succeeds. If any of these steps fails, the entire transaction fails and any changes made by previous steps are rolled back. For instance, if the ticket price is charged on the credit card, but booking the ticket fails, the charge on the credit card must be undone.

If all activities that make up the transaction execute successfully, all changes that were made as part of the transaction are committed. If the transaction fails, these changes are rolled back.

Reliable transactions have the following properties:


http://www.iona.com/support/docs/e2a/asp/5.0/j2ee/DevelopGuide/html/Jta-Bas5.html

posted @ 2007-06-29 15:59 lqx 阅读(224) | 评论 (0)编辑 收藏

转发(forward)、包含(include)及转向(redirect)的区别与联系

http://blog.csdn.net/lxxstarii/archive/2006/03/03/614628.aspx

posted @ 2007-06-29 15:19 lqx 阅读(192) | 评论 (0)编辑 收藏

[收藏]Spring--简单使用quartz实现定时作业

定时批处理作业是J2EE企业应用里很重要的一环,用来在晚间进行财务挂账,数据转存,新闻联播等等操作。

    而在Spring里,已经很好的集成了Quartz,简单到像配cron一样,在xml文件里面配一下时间就可以自动执行,不需要写一行代码。Spring对Quartz大刀阔斧的简化堪称范例,Quartz项目组也许可以学习一下。

    
<bean id="methodInvokingJobDetail"
        
class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
        
<property name="targetObject"><ref bean="financeDAO"/></property>
        
<property name="targetMethod"><value>confirmOrder</value></property>
    
</bean>


    
<bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
        
<property name="jobDetail">
            
<ref bean="methodInvokingJobDetail"/>
        
</property>
        
<property name="cronExpression">
            
<value>0 0 6,12,20 * * ?</value>
        
</property>
    
</bean>

    
<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
        
<property name="triggers">
            
<list><ref local="cronTrigger"/></list>
        
</property>
    
</bean>

上面这段配置文件规定了在早上6点和晚上8点执行financeDAO对象的confirmOrder()方法.


附:cronExpression配置说明

字段           允许值           允许的特殊字符
秒           
0-59           , - * /
分           
0-59           , - * /
小时           
0-23           , - * /
日期           
1-31           , - * ? / L W C
月份           
1-12 或者 JAN-DEC           , - * /
星期           
1-7 或者 SUN-SAT           , - * ? / L C #
年(可选)           留空, 
1970-2099           , - * /
The '*' character is used to specify all values. For example, "*" in the minute field means "every minute".
“*”字符被用来指定所有的值。如:”*“在分钟的字段域里表示“每分钟”。
The '?' character is allowed for the day-of-month and day-of-week fields. It is used to specify 'no specific value'. This is useful when you need to specify something in one of the two fileds, but not the other. See the examples below for clarification.
“?”字符只在日期域和星期域中使用。它被用来指定“非明确的值”。当你需要通过在这两个域中的一个来指定一些东西的时候,它是有用的。看下面的例子你就会明白。
The '-' character is used to specify ranges For example "10-12" in the hour field means "the hours 10, 11 and 12".
“-”字符被用来指定一个范围。如:“10-12”在小时域意味着“10点、11点、12点”。
The ',' character is used to specify additional values. For example "MON,WED,FRI" in the day-of-week field means "the days Monday, Wednesday, and Friday".
“,”字符被用来指定另外的值。如:“MON,WED,FRI”在星期域里表示”星期一、星期三、星期五”.
The '/' character is used to specify increments. For example "0/15" in the seconds field means "the seconds 0, 15, 30, and 45". And "5/15" in the seconds field means "the seconds 5, 20, 35, and 50". Specifying '*' before the '/' is equivalent to specifying 0 is the value to start with. Essentially, for each field in the expression, there is a set of numbers that can be turned on or off. For seconds and minutes, the numbers range from 0 to 59. For hours 0 to 23, for days of the month 0 to 31, and for months 1 to 12. The "/" character simply helps you turn on every "nth" value in the given set. Thus "7/6" in the month field only turns on month "7", it does NOT mean every 6th month, please note that subtlety.
The 'L' character is allowed for the day-of-month and day-of-week fields. This character is short-hand for "last", but it has different meaning in each of the two fields. For example, the value "L" in the day-of-month field means "the last day of the month" - day 31 for January, day 28 for February on non-leap years. If used in the day-of-week field by itself, it simply means "7" or "SAT". But if used in the day-of-week field after another value, it means "the last xxx day of the month" - for example "6L" means "the last friday of the month". When using the 'L' option, it is important not to specify lists, or ranges of values, as you'll get confusing results.
The 'W' character is allowed for the day-of-month field. This character is used to specify the weekday (Monday-Friday) nearest the given day. As an example, if you were to specify "15W" as the value for the day-of-month field, the meaning is: "the nearest weekday to the 15th of the month". So if the 15th is a Saturday, the trigger will fire on Friday the 14th. If the 15th is a Sunday, the trigger will fire on Monday the 16th. If the 15th is a Tuesday, then it will fire on Tuesday the 15th. However if you specify "1W" as the value for day-of-month, and the 1st is a Saturday, the trigger will fire on Monday the 3rd, as it will not 'jump' over the boundary of a month's days. The 'W' character can only be specified when the day-of-month is a single day, not a range or list of days.
The 'L' and 'W' characters can also be combined for the day-of-month expression to yield 'LW', which translates to "last weekday of the month".
The '#' character is allowed for the day-of-week field. This character is used to specify "the nth" XXX day of the month. For example, the value of "6#3" in the day-of-week field means the third Friday of the month (day 6 = Friday and "#3" = the 3rd one in the month). Other examples: "2#1" = the first Monday of the month and "4#5" = the fifth Wednesday of the month. Note that if you specify "#5" and there is not 5 of the given day-of-week in the month, then no firing will occur that month.
The 'C' character is allowed for the day-of-month and day-of-week fields. This character is short-hand for "calendar". This means values are calculated against the associated calendar, if any. If no calendar is associated, then it is equivalent to having an all-inclusive calendar. A value of "5C" in the day-of-month field means "the first day included by the calendar on or after the 5th". A value of "1C" in the day-of-week field means "the first day included by the calendar on or after sunday".

源自:http://www.blogjava.net/javaora/archive/2005/07/20/8070.aspx

posted @ 2007-06-21 17:37 lqx 阅读(174) | 评论 (0)编辑 收藏

html:select 使用

最近使用<html:select>标签,下面是我的一点体会:
1<html:select> 标签一点要嵌套在 <html:form> 标签中使用
2. 必须设置<html:select>的property属性,并且属性的名字要和 YourActionForm 中数据成员名相同,且提供getXXX() 和 setXXX() 方法. 提交表单后 property 属性中存放的就是用户的选择项
3. 下拉框用的是键/值对的模式,因此建议把数据存放在 LabelValueBean 对象中,并把这些对象存放在List中,也方便后续运用;
4. 在<html:select>标签中运用<html:options>来显示数据
   
<html:option collection="存放对象的List"
                          property
="value" 对应值
              LabelProperty
="label" 对应键/>
5. 这样就可以在页面中显示下拉框了

posted @ 2007-06-21 00:09 lqx 阅读(3033) | 评论 (0)编辑 收藏

[收藏]MySQL on Linux手动安装方法

1. 下载"mysql-standard-5.0.27-Linux-i686-icc-glibc23.tar.gz",推荐ICC版本,据称比GCC性能提高10-20%

2. 复制到/usr/local/,解压:tar zxvf mysql-standard-5.x.tar.gz

3. 添加用户和组mysql:

groupadd mysql

useradd -g mysql mysql

4. 创建符号连接:/usr/local # ln -s mysql-standard-5.x mysql

5. cd mysql,当前目录改为/usr/local/mysql/

6. 运行脚步初始化数据库:./scripts/mysql_install_db --user=mysql

7. 设置权限:

/usr/local/mysql # chown -R root .

/usr/local/mysql # chown -R mysql data

/usr/local/mysql # chgrp -R mysql

8. 根据需要创建并修改/etc/my.cnf,参考配置:

[mysqld]

# 设置默认为INNODB表,支持事务:

default-storage-engine=INNODB

# 设置默认的字符集:

default-character-set=utf8

# 禁用bdb:

skip-bdb

9. 启动MySQL:

/usr/local/mysql/bin # ./mysqld_safe --user=mysql &


10. 初始化root口令:

/usr/local/mysql/bin # ./mysqladmin -u root -p password "password-of-root"


Enter password: <输入旧口令,直接按Enter>

11. 以root登录创建数据库:

/usr/local/mysql # ./mysql -u root -p

Enter password: password-of-root


创建一个新用户:

mysql> create user test identified by 'test-password';


创建一个新数据库:

mysql> create database testdb;


赋予test用户从localhost访问testdb的权限:

mysql> grant all privileges on testdb.* to 'test'@'localhost';//此处是允许test用户通过本地访问数据库,如果想让test用户可以在任意地址访问该数据库可以写成     grant all privileges on testdb.* to 'test'@'%';

为test 用户设定密码:
1、首先以test用户登录到数据库,eg. mysql -utest -p
2、提示输入密码时直接回车即可。
3、进入mysql后使用如下命令可以为tes设定密码:SET PASSWORD = PASSWORD('biscuit');


停止MySQL服务器:

/usr/local/mysql/bin # ./mysqladmin -u root -p shutdown

Enter password: password-of-root

STOPPING server from pid file /usr/local/mysql/data/debian.pid

xxx mysqld ended
源自:http://www.linuxdiyf.com/viewarticle.php?id=48495
http://bbs.mysql.cn/thread-1614-1-1.html
http://www.chinaunix.net/jh/17/712043.html
关于mysql用户管理,参考:http://blog.chinaunix.net/u/19185/showart_156037.html

posted @ 2007-06-19 15:22 lqx 阅读(248) | 评论 (0)编辑 收藏

仅列出标题
共18页: First 上一页 9 10 11 12 13 14 15 16 17 下一页 Last