JDBC Access database steps in Java Web Popular explanations (meals), with MVC's popular explanation (cooking)

Source: Internet
Author: User
Tags access database

I.JDBC Access database steps popular explanation (eat)

1) Load Driver

Class.forName ("Com.microsoft.jdbc.sqlserver.SQLServer");

2) Establish a connection to the database

Connection ct=drevermanager.getconnection ("Jdbc:microsoft:sqlserver://localhost:1433;databasename=dbuser," sa "," SA ");

3) Create statement object

The statement object sends the SQL statement to the appropriate database and gets the result of the execution

Statement stmt=ct.createstatement ();

Explanation: For example, we go to eat Western food today, then we certainly do not go to the Chinese restaurant, loading the driver is the choice of what type of restaurants, not to go wrong, the restaurant waiter and the back kitchen is connected, because he will give the menu to the cook, rather than for example, health personnel to do this work, Establish a connection with the database we are going to find the waiter to let him order with our menu, instead of looking for a clean-up, a la carte, a la carte after the menu to cook, and finally wait for serving, create statement object is to write the menu, and then to the waiter, according to different requirements on different dishes, return different results

Two.the popular interpretation of MVC (cooking)

MVC meaning:

MVC is a design pattern that makes it mandatory to separate the input, processing, and output of an application. Using an MVC application is divided into three core parts, models, views, controllers. Each of them handles their own tasks.

The individual letters of MVC are M (model), V (view), C (Controller) Controllers

M is mainly done by Java class, or it can be Java bean, EJB, etc.

V done by JSP

C is done by the servlet.

Popular example: do a dish first to find good raw materials, this is the JSP, and then processed to cook, this is the servlet, in the process needs a variety of cooking pot, spoon, etc., this is the Java class (Implementation method), and finally get the results from the JSP display

JDBC Access database steps in Java Web Popular explanations (meals), with MVC's popular explanation (cooking)

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.