Connect to a remote database (application and database separation) _ MySQL

Source: Internet
Author: User
Connect to remote database (application and database separation) bitsCN.com


Connect to a remote database (application and database separation)

If you are a database veteran, ignore it...

If you are a beginner in the database, continue...

Recently, when I was working on a project, I encountered a problem: physically separating the database from the application...
So, find information online and make a summary,

A patchwork.

Scenario and Lan are all XP systems:

PC name IP address environment configuration

PC1 192.168.0.2 application

PC2 192.168.0.3 database

1. install mysql on PC2... Please use your own Baidu; user name root, password root...

2. install ide such as myeclipse on PC1... Baidu on your own;

3.pc2run mysql.exe and the command

Grant all privileges on *. * TO 'root' @ '192. 168.0.3 'identified by 'root' with grant option;

Allow the user root to connect to the mysql server from the host whose ip address is 192.168.0.3 (if the ip address of the command line is changed to %, the user can connect to the mysql server from any address ), use root as the password. remember to flush privileges ;;

4. configure dbcp. properties of PC1. my configuration is as follows:

DriverClassName = com. mysql. jdbc. Driver

Url = jdbc/: mysql //: // 192.168.0.3/: 3306/myfirstremotedb? CharacterEncoding/= UTF-8 & zeroDateTimeBehavior/= convertToNull

Username = root

Password = root

InitialSize = 5

MaxActive = 10

MaxIdle = 10

MinIdle = 0

MaxWait = 60000

ConnectionProperties =

DefaultAutoCommit = true

(The Blue font is the database name, and the yellow background is in the same line )...

5. coding... Run! That's it!

BitsCN.com

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.