Eclipse connects Oracle Databases

Source: Internet
Author: User
Tags port number

Because Eclipse is an open source product, many of the tools are installed in the form of plug-ins that users choose to install, and many articles mention how to connect to the database, but there is no indication of how the database needs to be loaded and how to load it. jar, now added as follows,

To the Feast of posterity!

1. Under D:\oracle\ora92\jdbc\lib (your Oracle installation directory) there are many. jar package files, copy the Ojdbc14.jar to your project, right-click the file, select "Build Path" to select the "Import" option, You can now open and use the class file under the package. Of course, you can also, put the driver in the CLASSPATH environment variable, the other class package settings are similar!

2. Loading and registering the driver.

Class.forName ("Oracle.jdbc.driver.OracleDriver");

After the driver is loaded, a driver object is typically created and automatically registered by calling Drivermanager.registerdriver ().

3, establish the connection.

Drivermanager.getconnection ("Jdbc:oracle:thin: @localhost: 1521:LC", Name,pass);

The standard syntax for the JDBC URL is as follows:

<protocol>:<subprotocol>:<data Source Identifier>

It is divided into three parts:

Protocol: Main communication protocol

Subprotocol: A minor communication protocol with its driver name

Data source identifier: sources

As shown in the previous example:

"Jdbc:oracle:thin" is a communication protocol, @ after the "valid host address, then the port number, the default is: 1521. Then your data source, you must know that the following is the username and password, of course, can also write the following forms:

Connection con= drivermanager.getconnection ("JDBC:ORACLE:THIN:NAME/PASS@LOCALHOST:1521:LC");

Returned a connection object to con,

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.