jdbc DriverManager.getConnection(“connection_url”, “username”, “password”);

前端 未结 2 1859
轻奢々
轻奢々 2021-01-27 14:43

Can anyone tell me wats happening here

Connection con =DriverManager.getConnection(\"connection_url\", \"username\", \"password\");

How connec

2条回答
  •  伪装坚强ぢ
    2021-01-27 15:14

    The DriverManager keeps track of all JDBC Drivers that have been loaded in your JVM (there are a couple of ways in which a Driver can be loaded).

    When you ask the DriverManager to open a connection for you, it asks each of the loaded drivers whether it can handle the URL that you've specified.
    If the Driver can handle the URL, then it is asked to connect to the database using the supplied username and password. The Driver supplies a connection object that implements the Connection interface.

    The DriverManager really is just a small class that knows about each loaded Driver and handles picking the right one. The implementation of Connection (and Statement, etc) is all handled by the Driver.

提交回复
热议问题