Java Database Operations

Source: Internet
Author: User

First, JDBC

1.JDBC

Java database connection, used in Java programs to implement database operations, JAVA.SQL package provides the execution of SQL statements, access to a variety of database methods, and for a variety of different databases to provide a unified interface and classes of operations.

2. Operation procedure

  1. Load the JDBC drive and load the JDBC driver into the classpath.
  2. Load the JDBC driver and register it in DriverManager. General use of reflection mechanism Class.forName (String drivername)
  3. Establish database connection, get Connection object. Typically implemented through the Drivermanager.getconnection (url,username,passwd) method, where the URL represents a string that connects to the database, Uaername represents the user name of the connection database, and passwd represents the password for the connection database.
  4. Establishes a statement object or Preparestatement object.
  5. Executes the SQL statement.
  6. Accesses the structure set ResultSet object.
  7. Access resultset, Statement, PreparedStatement, and connection objects down, freeing up the resources that are occupied.

3. Cite an example of accessing MySQL

Ii. methods used by JDBC to process transactions

Java Database Operations

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.