简体   繁体   English

为什么java.sql.Statement破坏了向后兼容性?

[英]Why does java.sql.Statement break backward compatibility?

There are three more methods declared in Statement interface since version 1.6. 自1.6版以来, Statement接口中还Statement三种方法。

As I understand, this breaks one of the biggest java advantages - backward compatibility. 据我了解,这打破了Java最大的优势之一-向后兼容。 My project just not compiled any more after transition from jdk 1.5 to jdk 1.6 and I have to change the code. 从jdk 1.5过渡到jdk 1.6之后,我的项目不再编译了,我不得不更改代码。

What is the reasoning of adding these three methods ( isPoolable , setPoolable , isClosed ) in such a bad way? 以如此糟糕的方式添加这三种方法( isPoolablesetPoolableisClosed )的原因是什么?

Added interface methods are a problem if you implement the interface eg you are writing your own JDBC driver. 如果您实现接口,则添加的接口方法将成为问题,例如,您正在编写自己的JDBC驱动程序。 If you have a library which uses these method calling a library which doesn't implement these methods you will get a NoSuchMethodError. 如果您有一个使用这些方法的库调用了一个未实现这些方法的库,则会收到NoSuchMethodError。

I assume these methods were added because for most use cases its considered harmless. 我假设添加了这些方法,因为对于大多数用例而言,它被认为是无害的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM