一个在Spring里使用quartz完成时序调度工作的例子
Spring提供了支持时序调度的整合类。现在, Spring支持内置于1.3版本以来的JDK中的Timer和Quartz Scheduler(http://www.quartzscheduler.org)。 两个时序调度器通过FactoryBean建立,保持着可选的对Timers或者Triggers的引用。更进一步的, 对于Quartz Scheduler和Timer两者存在一个方便的类允许你调用目标对象(类似于通常的MethodInvokingFactoryBeans)上的某个方法。
Commons Logging自动发现日志工具过程和Log4j的初始化
Jakarta Commons Logging (JCL)提供了统一的日志接口,它目的是成为轻量级和不依赖其他日志工具的抽象层。它把一个简单的日志抽象提供给二次开发者,它允许用户插入一个指定的日志实现。
JCL为其他日志工具提供了一个代理日志实现,包括Log4J,Avalon LogKit,JDK 1.4,以及JDK1.4日志API的实现。这个接口类似的映射到Log4j和LogKit。
下面是Commons Logging (JCL)自动地发现选择一个日志实现工具的过程:
Hibernate optimistic locking exception
HibernateOptimisticLockingFailureException,The error occurs because at least 2 transactions are working on the same record(s). If a record is read by 2 transactions, and if the record is saved by one transaction first, and then by the second one, an optimistic locking exception is thrown in the second transaction, because the assumption that nobody else was going to modify the record, doesn't hold. (Optimistic locking = You are optimistic about the facts that nobody else is going to need the same record)
Are you using multithreading in batch mode? Probably multiple transactions are modifying the same record at the same moment.
There are different solutions:
1) make sure (by design) that records that are going to be updated, are touched by only a single transaction at any given moment
2) instead of optimistic locking, use pessimistic locking (problem: reduces scalability, and added complexity in application)
3) retry the transaction: make sure that no non-transactional state is kept between retries.
我收藏的链接5
使用Jmeter进行需登录的Web页面性能压力测试
使用Jmeter进行需登录的Web页面性能压力测试,首先必须解决登录的问题。要登录,应该模拟登录过程,即传递用户名和密码请求登录处理URL进行登录,然后让Jmeter维护会话Session,在同一个会话Session里,继续请求目标测试页面,进行测试。在Jmeter里有两种机制可以维护Session会话,一是新建HTTP URL Re-writing Modifier,一个是新建HTTP Cookie 管理器。在HTTP URL Re-writing Modifier需要指定session参数名称,有的是jsessionid、JSESSIONID,有的是其他名字,所以我觉得还是HTTP Cookie Manager好,它会自动地维护一个会话Session。
log4j在集群cluster环境下运行
log4j在集群cluster环境下运行,需要将log4j.properties文件脱离应用,将每个集群节点分别指定对应的log4j.properties。在启动服务器JVM的时候加入参数:
-Dlog4j.configuration=file:/home/bea/log4j1.properties
这样可以在一台物理服务器机器上配置多个集群服务器实例。
Java和时区(Time zones and Java)
Thread Dump 和Java应用诊断
用下列方法可以产生Thread Dump信息:
1,Solaris OS
<ctrl>-’\’ (Control-Backslash)
kill -QUIT <pid>
2, HP-UN/UNIX/Linux
Kill -3 PID
PID通过下面方法获取
ps -efHl | grep 'java' **. **
3,Windows
直接对MSDOS窗口的程序按Ctrl-break
在Hibernate里使用Oracle的强制索引查询提示hints
在Hibernate Hql里使用数据库某些特殊的功能,例如使用Oracle的查询提示(hints)(如强制Oracle使用某个索引),使用用户自定义的数据库函数等,Hibernate的官方文档里已经有提到这个,不能使用Hql做数据库查询提示,而是使用三种Hibernate查询方法HQL,Criteria Queries,Native SQL里的Native SQL 本地SQL。
Oracle专家调优秘密
在过去的十年中,Oracle已经成为世界上最专业的数据库之一。对于IT专家来说,就是要确保利用Oracle的强大特性来提高他们公司的生产力。最有效的方法之一是通过Oracle调优。它有大量的调整参数和技术来改进你的Oracle数据库的性能。
