Differences between connecting database localhost and 127.0.0.1

Source: Internet
Author: User
Use JDBC to access Oracle, that is, when java connects to the local database, the address can be localhost or 127.0.0.1. But what is the difference between the two? Which one is better? Many people think that these two are completely the same, and some people think 127.0.0.1 is better, because it is a local IP address and does not need to be resolved from the domain name. In fact, these two are very different: localhost

Use JDBC to access Oracle, that is, when java connects to the local database, the address can be localhost or 127.0.0.1. But what is the difference between the two? Which one is better? Many people think that these two are completely the same, and some people think 127.0.0.1 is better, because it is a local IP address and does not need to be resolved from the domain name. In fact, these two are very different: localhost

Use JDBC to access Oracle, that is, when java connects to the local database, the address can be localhost or 127.0.0.1. But what is the difference between the two? Which one is better?
Many people think that these two are completely the same, and some people think 127.0.0.1 is better, because it is a local IP address and does not need to be resolved from the domain name. In fact, these two are very different:

Localhost is also called local. The correct explanation is: local server

The correct explanation of 127.0.0.1 in the system is: local address (local server)

Localhot (local) is transmitted without a Nic! This is important because it is not restricted by network firewalls and network adapters. Access to localhost will not be resolved to an ip address, and will not occupy Nic or network resources.

127.0.0.1 depends on the network card and is restricted by the network firewall and network card.

This is why it is sometimes accessible using localhost, but not 127.0.0.1.

So use localhost whenever possible.

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.