Help me connecting java and oracle -
Can someone explain me these sections and methods?
DriverManager.registerDriver (new oracle jdbc.driver.OracleDriver ()); Conn = java.sql.DriverManager.getConnection ("jdb: ocracle: thin: username /password@machine.us.company.com: 1234: dbsid"); Thanks
Let's decode lines of your code blocks : 1 DriverManager.registerDriver 2. (New oracle.jdbc.driver.OracleDriver ()); 3. conn = java.sql.DriverManager.getConnection (4. "JDBC: Oracle: Slim: Username / Password- Machine.us.company.com: 1234: DBSID");
Line 2:
creates a new instance of oracle.jdbc.driver.OracleDriver
, a JDBC driver
JDBC driver for Oracle database implements the interfaces and classes defined by the JDBC API that programmers use to connect and query the database.
Line 1
Researchers are working between oracle.jdbc.driver.OracleDriver
which is the traditional management layer of JDBC, user And the driver operates to establish a connection between a database and the appropriate driver.
Line 3:
Now when the communication layer between the JDBC application and the database is ready, you can make a connection by calling the method of class.
> Line 4:
This is the "connection string" or "database URL". This string
recognizes the database that you want to connect to. The scheme of this URL is specific to the database provider and / or driver (here, Oracle and its "credit" driver).
Note that prior to Java 6, the JDBC driver was the preferred way to load and register to call class.forName
. To make the call, driver
was the responsibility
[...] All drivers
classes have a static section (a static initiator) Should be written along which creates an example of class and then registers it drivermoiner
class when it loads. In this way, a user will not normally call DriverManager.registerDriver
; It is automatically loaded by the driver
class when it is loaded.
Check out the chapter from the JDBC documentation for more information.
Comments
Post a Comment