每次我查看JDBC程序员的教程时,似乎都将连接设置为null
Connection conn = null;
我无法弄清楚原因。有人可以为我澄清一下吗?
答案 0 :(得分:0)
通常情况下,} finally {
// ...
if (conn != null) {
try {
conn.close();
} catch (Exception e) {
}
}
}
块可以包含支票
null
如果没有conn
的默认初始化,您将收到 /**
* Sets the header bar's attributes
*
* @param inverse bool Whether the color scheme should be inverted
* @param button bool Whether the back button should be presented
* @param link string The route the back button will take the user to when pressed
* @param title string The translation key to use for the title to be shown in the headerbar
* @param data string Characters to be inserted in the span next to the title
*
**/
return {
set: function(inverse, button, link, title, data) {
// set defaults
inverse = typeof inverse !== 'undefined' ? inverse : false;
button = typeof button !== 'undefined' ? button : false;
link = typeof link !== 'undefined' ? link : $state.current.name;
title = typeof title !== 'undefined' ? title : undefined;
data = typeof data !== 'undefined' ? data : false;
// store for HeaderController to retrieve
$localStorage.headerInverse = inverse;
$localStorage.headerBackButton = button;
$localStorage.headerBackLink = link;
$localStorage.headerTitle = title;
$localStorage.headerData = data;
broadcast.announce('setHeader');
}
};
可能尚未初始化的错误。