官术网_书友最值得收藏!

Learning about JDBC driver

Java Database Connectivity (JDBC) is an Application Programming Interface (API), which defines how a client should access and interact with a database from Java. Each provider (IBM, Oracle, Sun, Microsoft, and others) implements the mechanism (the "How To") for its own product, allowing the client not to be bothered with the details of each implementation and worrying only about its interface. In Java slang, this is known merely as a controller or JDBC driver.

Note

A JDBC driver, generally speaking, consists of one or various files with a .jar extension, which must be copied on a certain path (Java CLASSPATH, that is) so that applications can make use of it instead.

In order for a JDBC driver to be used, Java programs require the following information:

  • URL: This is a string that specifies, among other things, the protocol, location of the server, port, and name of the database.
  • Driver: This is the name of the class that implements the java.sql.Driver interface.
  • User: This is the user with the necessary privileges on the database engine (this parameter might be optional depending on the case).
  • Password: This is the password corresponding to the user (this parameter might also be optional).

In some cases, the inclusion of the user and password is supported within the URL, so we only need to define the URL and Driver parameters.

The syntax to indicate the URL and driver class name should always be present in the implementation documentation of each provider.

For example, in the case of MySQL, the information regarding the implementation can be found in the following web page:

http://dev.mysql.com/downloads/connector/j/5.1.html

The implementation details are as follows:

  • Driver: com.mysql.jdbc.Driver
  • URL: jdbc:mysql://localhost:3306/MyDataBase
  • Protocol: jdbc:mysql
  • Name server: localhost (local address)
  • Port: 3306 (default port)
  • Database: MyDataBase
主站蜘蛛池模板: 开阳县| 沭阳县| 方山县| 攀枝花市| 彰化市| 轮台县| 湖北省| 富阳市| 汝城县| 徐水县| 绿春县| 嘉荫县| 吴堡县| 鱼台县| 彩票| 南陵县| 盈江县| 东乡族自治县| 哈密市| 柳河县| 西林县| 永昌县| 稷山县| 河南省| 正安县| 万州区| 隆林| 肇源县| 郧西县| 云霄县| 苍梧县| 雅江县| 藁城市| 江源县| 和平区| 乐东| 兴文县| 濮阳县| 常宁市| 安丘市| 榆社县|