JDBC实现如何工作 [英] How JDBC implementation works

查看:92
本文介绍了JDBC实现如何工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在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实现如何工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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