JDBC Anatomy Chapter (1): Class.forName () in Java

Source: Internet
Author: User

When using JDBC to connect to a database in Java, the following statements are often used to implement, but seldom go into the

Class.forName ("Com.mysql.jdbc.Driver");
Con=drivermanager.getconnection ("jdbc:mysql://" +dbserver+ ":" +dbport+ "/" +dbname,username,password ");

Today we're going to see why we're doing this, and how it's achieved.

Resources article:

Http://www.jb51.net/article/46011.htm

http://www.zhihu.com/question/22925738

Http://www.cnblogs.com/sunzn/p/3187868.html

Http://www.360doc.com/content/10/0712/10/1720440_38421273.shtml

The JVM does not execute static code when it loads the class, it executes only when it is initialized.

Understand:

JDBC Anatomy Chapter (1): Class.forName () in Java

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.