在JDBC中,我看到 Connection 是一个接口,它定义了与数据库交互的方法。
In JDBC, I see that Connection is an interface, which defines methods for interacting with Database.
我也知道接口只包含抽象方法,并且无法实例化
I also know that interface contains only abstract methods, and cannot be instantiated
但是在JDBC代码中,以下是如何工作的,
But In JDBC code, how does the following work,
Connection connection = DriverManager.getConnection("URL String"); Statement statement=connection.createStatement();据我所知 createStatement()应该是一个抽象的方法,我...,没有任何身体
As per my doubt createStatement() should be a abstract method, i..e, without any body
但是每件事情都很好......用这个
But every thing works fine... with this
任何人都可以解释一下吗?
Can anyone explain?
推荐答案DriverManager.getConnection 返回一个实现连接接口的对象 - 在幕后有一个真实的对象。
DriverManager.getConnection returns an object which implements the Connection interface - behind the scenes there is a real object.
更多推荐
JDBC实现如何工作
发布评论