JDK7中真的有`ResultSet.getObject(String,Class< T>))吗? [英] Is there really `ResultSet.getObject(String, Class<T>) in JDK7?

查看:181
本文介绍了JDK7中真的有`ResultSet.getObject(String,Class< T>))吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在JDK7中看到了很多更改的接口,例如,添加了 ResultSet.getObject(String,Class< T>)。我对这种不兼容的更改感到非常惊讶,特别是因为我从未见过有关它的讨论。

I see quite a few changed interfaces in JDK7, e.g., the addition of ResultSet.getObject(String, Class<T>). I was greatly surprised by this incompatible change, especially because I've never seen it discussed.

我想当我使用JAR文件代替而不是不兼容时并不重要试图自己编译项目,对吧?

I suppose the incompatibility doesn't matter when I use a JAR file instead of trying to compile the project myself, right?

同时支持JDK6和JDK7的正确方法是什么?

What is the proper way to support both JDK6 and JDK7? Does simply implementing the new methods and never using them suffice?

推荐答案

似乎

<T> T getObject(int columnIndex, Class<T> type) throws SQLException

<T> T getObject(String columnLabel,  Class<T> type) throws SQLException

。 (至少说从1.7开始)在文档。我同意,这是一个令人讨厌的更改。

were introduced in 1.7. (At least it says "Since 1.7") in the documentation. I agree, it's kind of a nasty change.

java.sql 接口还有更多更改。例如, Connection 在1.7中有5种新方法。希望这些重大更改是值得的。

There are more changes in the java.sql interfaces. Connection for instance, got 5 new methods in 1.7. Hopefully the breaking changes are worthwhile.


简单地实现新方法而不用它们就足够了吗? >

Does simply implementing the new methods and never using them suffice?

是,但是避免使用 @Overrides 批注界面的早期版本中没有的方法。

Yes, but avoid using the @Overrides annotation on methods not present in the earlier version of the interface.

这篇关于JDK7中真的有`ResultSet.getObject(String,Class&lt; T&gt;))吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆