Effective Java 学习笔记 (7)
Finalizer 不可计划的,也是危险的,一般也是不必要的. 不能在finalizer中放任何与依赖时间相关的操作,因为你不知道它什么时候被执行. 比如在finalizer中关闭文件的做法就是错误的, 根据JVM的实现方式不同,有可能导致打开的文件数过多而无法再打开文件. 也不能在finalizer中改变状态,如给数据库解锁等. finalizer还能带来严重的性能问题, 显示的调用的终止函数可以采用try -finally的语句 当然,合法的使用finalizer有两种情况: 一种是做为最后的一道关卡,检测用户是否有没有被释放的资源,如果有则释放它,并打印出警告. 虽然不提倡在finalizer中释放资源,但晚释放总比不释放好(beter later than never) 还一种合法使用就是在使用 native方法的时候. 要注意,finallizer没有承继关系,在子类中必须显示调用父类中的函数.
相关文档:
/*
* @(#)MemoryMonitor.java 1.3 05/11/17
*
* Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are ......
来源:http://www.ej38.com/showinfo/java-132636.html
使用jar包:
commons-pool-1.5.3.jar,tomcat-naming-common.jar,commons-pool-1.5.3-bin.zip,commons-dbcp.jar
注意:jdbc 驱动要与数据库兼容.
package test.comm;
import java.sql.Connection;
import java.sql.SQLException;
import java.u ......
我今天学习了sql语句的常用函数,是冯威老师讲的,我做了简单的笔记:
一,SQL函数:
1. 大小写转换函数
lower 转成小写
upper 大写
initcap 将字符串的(每个单词的)第一个字母变为大写,后面的小写
select initcap('huangHY') from dual
&n ......
我今天学习了Oracle数据库如何修改表的知识,是冯威老师讲的课,我做了简单的记录:
1.在表中插入新的列:
alter table tablename
add city varchar(2) default 'rr' //赋默认值
2.修改表中的列:
alter table tablename
modify city varchar(20)
3.删除表中的列:
alter t ......
public class Bean1 {
private String strValue;
private int intValue;
private List listValue;
private Set setValue;
private String[] arrayValue;
private Map mapValue;
public String getStrValue() {
return strValue;
}
public void setStrValue(String strValue) {
t ......