恐怕不是你想象的这样(不过conn.createStatement()确实是应用多态的,不过这个在这里根本不是主要的,因为JAVA语言机制直接支持多态所以任何方法都可能是多态的也都可以说是多态的。)。解释起来好麻烦。
我建议你看看JDK API,其实我估计你还需要学很多周边的知识才能很好的理解。
public interface StatementThe object used for executing a static SQL statement and returning the results it produces. By default, only one ResultSet object per Statement object can be open at the same time. Therefore, if the reading of one ResultSet object is interleaved with the reading of another, each must have been generated by different Statement objects. All execution methods in the Statement interface implicitly close a statment's current ResultSet object if an open one exists. connection的API的说明内容相对多就不贴。
我建议你看看JDK API,其实我估计你还需要学很多周边的知识才能很好的理解。
public interface StatementThe object used for executing a static SQL statement and returning the results it produces. By default, only one ResultSet object per Statement object can be open at the same time. Therefore, if the reading of one ResultSet object is interleaved with the reading of another, each must have been generated by different Statement objects. All execution methods in the Statement interface implicitly close a statment's current ResultSet object if an open one exists. connection的API的说明内容相对多就不贴。
Statement stmt = conn.createStatement();
的初始化用到工厂模式了吗?
我是初学者,如果说错了请勿见笑。谢谢!
接口当然是多态的了。其实只是多态的一种表现。可能你接触的还用了连接池技术。共同努力啊!
(书名可能不是很正确),是红皮,相同系列出一堆的那套的。
有关于JDBC的一些讨论,可以看看。
其中JDBC/ODBC就是一个适配器的应用。当然这些不是很容易讲清楚了。阎宏的设计模式里也在适配器模式中提到过jdb。感兴趣的可以去看看:)