下面的代码
public class Test16Jit {
public static void main(String[] s) {
int max = Integer.MAX_VALUE;
int i = 0;
long li = 0;
while (i >= 0) {
i++;
li++;
if (i > max) {
System.out.println("i is : " + i);
System.out.println("max is : " + max);
System.out.println("Woo!! something really went wrong");
}
}
System.out.println("Value of i: " + i);
System.out.println("Total # of iterations: " + li);
}
}
Run Code Online (Sandbox Code Playgroud)
java 1.7x中的输出如下
Value of i: -2147483648
Total # of iterations: 2147483648 …Run Code Online (Sandbox Code Playgroud) 我试图找出在处理JDBC中的连接时进行try / catch的最佳方法是什么。
我个人的看法是。
Connection conn = null;
try{
conn = getDBConnection();
//Some jdbc code
} catch(SQLException e) {
//...
} finally {
if(conn != null) {
try {
conn.close();
} catch(SQLException e) {
//....
}
}
}
Run Code Online (Sandbox Code Playgroud)
但我见过很少有聪明的人这样做
Connection conn = null;
try{
conn = getDBConnection();
//Some jdbc code
conn.close();
conn = null;
} catch(SQLException e) {
//...
} finally {
if(conn != null) {
try {
conn.close();
} catch(SQLException e) {
//....
}
}
}
Run Code Online (Sandbox Code Playgroud)
在try中关闭连接并将其设置为null有什么好处?
让我们说我有一个Employee在Oracle 中调用的表,其结构如下.
EMPLOYEE:
NAME VARCHAR2(60)
DOB TIMESTAMP
SAL NUMBER
Run Code Online (Sandbox Code Playgroud)
我想要一个查询,选择DOB属于月末的所有员工.
即(1/31,2/28或2/29,基于年份,3/31 ....)