You are browsing the archive for Java开源.

Avatar of hailor

by hailor

学习与使用Spring Security2(一)

八月 5, 2009 in Java开源

Spring Security2是一套安全验证框架,与它的前一个版本acegi相比,简化了很多配置的工作,因为很多配置都已经自动完成了。下面就开始体验一下Spring Security2配置的简单与强大。在本文中将介绍Spring Security2的基本使用。

Read the rest of this entry →

Avatar of hailor

by hailor

Oracle JDBC无法取得时分秒

七月 23, 2009 in Java开源

在项目中使用的Oracle JDBC版本为Oracle JDBC Driver version – 9.0.2.0.0,由于使用了Hibernate,所以一直没有发现使用native sql查询时时间类型会丢失时分秒。测试程序如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
public class TestDate {
	public static void main(String[] args) {
		Connection connection = null;
		try {
			Class.forName("oracle.jdbc.driver.OracleDriver");
			try {
 
				connection = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","exthosf","exthosf");
				PreparedStatement ps=connection.prepareStatement("SELECT sysdate FROM dual");
			    ResultSet rs=ps.executeQuery();
			    while(rs.next())
			    System.out.println(rs.getObject(1));	
			} catch (SQLException e) {
				e.printStackTrace();
			}
 
			if (connection != null) {
				System.out.println("取得连接 :)");
			} else {
				System.out.println("无法取得数据库连接!");
			}
 
		} catch (ClassNotFoundException e) {
			System.out.println("无法找到数据库连接驱动!");
			e.printStackTrace();
 
		} finally {
			try {
				// 检查连接是否为空,如果不为空则关闭
				if (connection != null) {
					connection.close();
				}
			} catch (SQLException e) {
				System.out.println("关闭连接时发生错误");
			}
		}
 
	}
}

使用Oracle JDBC Driver version – 9.0.2.0.0 得到的结果如下:

2009-08-05

取得连接 :)

作用 Oracle JDBC Driver version – “11.1.0.6.0-Production*” 得到的结果如下:

2009-08-05 20:12:27.0
取得连接 :)

解决ClassNotFoundException: org.hibernate.hql.ast.HqlToken

七月 16, 2009 in Java开源

由于项目需要,近日正对jBPM4.0进行研究。在试图将工作流发布到WebLogic11g即WebLogic10.3中时遇到了比较棘手的异常:ClassNotFoundException: org.hibernate.hql.ast.HqlToken,在经过查询资料并进行代码追踪和研究后发现产生该异常的原因是:在jBPM4.0中,使用的Hibernate是3.0之后的版本,而从3.0开始就采用了新的基于ANTLR的查询翻译器,在WebLogic中使用的是antlr2.6.1.jar,无法满足该要求,需要从新版本的Hibernate中提取该jar并添加到WebLogic的Classpath中。

基于以上分析便有了以下解决方案:

Read the rest of this entry →

JVM, Connection Pool相关的Metalink文章

五月 17, 2009 in Java开源

 

Oracle Metalink上有很多JVM和连接池相关的文章,为了使用方便,将其纪录汇总

 

1,监控OC4J连接池情况

567784.1 How To Monitor A Connection Pool Within OC4J 10.1.3.x Remotely
本文描述如何使用Oracle提供的工具来监控OC4J下连接池的情况,确保已正确释放连接

 

2,监控OC4J JVM信息

734481.1 How To Monitor The JVM For OC4J 10.1.3.x Remotely
本文描述了如何使用Oracle提供的工具来监控OC4J的JVM,查看JVM堆,线程和相关JVM信息

 

3,监控OC4J JVM内存使用情况

443506.1 How to monitor memory usage in OC4J 10.1.3.x
本文描述如何通过各种方式和工具来监控OC4J的JVM内存使用情况

 

4,如何编写程序来确保无ResultSet/Connection/Statement泄露

402480.1 How To Ensure No ResultSet/Connection/Statement Leaks Exist in Your JDBC Code
本文描述了如何编写JDBC相关程序来确保没有ResultSet/Connection/Statement泄露,避免:ORA 1000 -  “maximum open cursors exceeded”;ORA 20 – “maximum number of processes (%s) exceeded”. 之类的数据库错误发生

 

5,EBS11i R12 JVM相关

362851.1 Guidelines to setup the JVM in Apps Ebusiness Suite 11i and R12
567551.1 Configuring various JVM tuning parameters for Oracle E-Business suite 11i and R12
462550.1 Generate JVM heap dump in E-Business suite 11i and R12

 

使用jstatd和visualVM监控JVM

五月 13, 2009 in Java开源

 

VisualVM是集成了多个JDK命令工具的一个可视化工具,它主要用来监控JVM的运行情况,可以用它来查看和浏览Heap Dump、Thread Dump、内存对象实例情况、GC执行情况、CPU消耗以及类的装载情况。

在JDK Update7之后,VisualVM作为JDK的一部分发布,但同时VisualVM也发布独立的版本。VisualVM必须运行在JDK1.6以上的VM环境下,但可以用它来监控JDK1.4以上的JVM。

Read the rest of this entry →