据说在使用后关闭所有JDBC资源是一个好习惯.但是,如果我有以下代码,是否有必要关闭Resultset和Statement?
Connection conn = null;
PreparedStatement stmt = null;
ResultSet rs = null;
try {
conn = // Retrieve connection
stmt = conn.prepareStatement(// Some SQL);
rs = stmt.executeQuery();
} catch(Exception e) {
// Error Handling
} finally {
try { if (rs != null) rs.close(); } catch (Exception e) {};
try { if (stmt != null) stmt.close(); } catch (Exception e) {};
try { if (conn != null) conn.close(); } catch (Exception e) {};
}
Run Code Online (Sandbox Code Playgroud)
问题是连接的关闭是否完成了工作,或者是否使用了一些资源.
"bundle"的含义是什么,例如在这种依赖中:
<dependency>
<groupId>org.apache.abdera</groupId>
<artifactId>abdera-core</artifactId>
<version>1.1.2</version>
<type>bundle</type>
<scope>compile</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud) 怎么可以^\d+$改善不允许0?
编辑(使其更具体):
允许的示例:
1
30
111
不允许的示例:
0
00
-22
如果允许或不允许具有前导零的正数(例如022),则无关紧要.
这适用于Java JDK Regex实现.
声明是
SELECT * FROM tableA WHERE x = ?
Run Code Online (Sandbox Code Playgroud)
并通过java.sql.PreparedStatement'stmt'插入参数
stmt.setString(1, y); // y may be null
Run Code Online (Sandbox Code Playgroud)
如果y为null,则语句在每种情况下都不返回任何行,因为x = null它始终为false(应该是x IS NULL).一个解决方案是
SELECT * FROM tableA WHERE x = ? OR (x IS NULL AND ? IS NULL)
Run Code Online (Sandbox Code Playgroud)
但后来我必须设置两次相同的参数.有更好的解决方案吗?
谢谢!
如果类路径中有两个JAR文件,则两个JAR文件的根目录中都包含名为"config.properties"的资源.有没有办法检索两个类似的文件getClass().getResourceAsStream()?订单无关紧要.
另一种方法是在类路径中加载匹配某些标准的每个属性文件,如果可能的话.
这是一个关于如何使用Angular 2以"正确"方式实现所需功能的概念性问题.
我的应用程序有一个导航菜单,一个工具栏和一个内容区域.后者包含主要内容<router-outlet>并显示不同的视图,如列表和详细信息.
我想要实现的是工具栏显示不同的组件,具体取决于在内容区域中呈现的组件/视图.例如,列表组件需要工具栏中的搜索控件,而详细信息组件需要保存按钮.
A)我的第一次尝试是<router-outlet>在工具栏中添加另一个(命名)并根据静态路径显示工具栏组件.这有什么不妥之处:
B)我的第二次尝试是命令性地导航到主视图组件中的工具栏组件(也使用命名的工具栏插座),ngOnInit它更紧密地耦合它.什么闻起来很糟糕:
ngOnDestroy,但我还没有发现如何.C)给路由器一个最后的机会,因为我发现这种工作:
const ROUTES: Routes = [
{path: "buildings", children: [
{path: "", component: BuildingListComponent, pathMatch: "full", outlet: "primary"},
{path: "", component: BuildingListToolbarComponent, pathMatch: "full", outlet: "toolbar"},
{path: ":id", component: BuildingDashboardComponent, outlet: "primary"}
]}
];
Run Code Online (Sandbox Code Playgroud)
这个想法是路由器会选择每个插座的匹配路径.但是(不,它可能很容易)不幸的是,这不起作用:
const ROUTES: Routes = [
{path: "buildings", children: [
{path: "list", component: BuildingListComponent, pathMatch: "full", outlet: "primary"},
{path: "list", component: BuildingListToolbarComponent, …Run Code Online (Sandbox Code Playgroud) 虽然我看过很多类似的问题,但我没有找到明确的答案.使用Servlet Spec 2.5,是否可以通过编程方式添加servlet过滤器和映射?首选位置位于Servlet.init()或ServletContextListener.contextInitialized()中.
我想以编程方式(从Servlet init()内)注册/添加Managed Bean类到应用程序范围.我怎么能用JSF 1.2做到这一点?
我了解到它来自魔鬼,==而不是测试字符串相等String.equals(),因为每个String都是对它自己的对象的引用.
但如果我使用类似的东西
System.out.println("Hello" == "Hello");
Run Code Online (Sandbox Code Playgroud)
它打印真实.
为什么?
我有一个ListView,里面有几个项目.当ListView失去焦点时,最后选择的ListViewItem仍然被"选中",背景为灰色.
我想在ListView.FocusLost上实现它,选择已经消失,因此将发生ListView.SelectedIndexChanged事件.
有任何想法吗?
我使用的是.NET CF 3.5.