JDBC and java.sql

Source: Internet
Author: User

JDBC Connection Operation database process :
1. Place the database-driven jar package under the Lib folder.

2. Define driver name (driver), database Url,username,password string constant

3. Register database driver Class.forName ()

4. The Driver management Class (DriverManager) implements the connection interface.

5. Get resultset results by executing SQL statements from the statement class

6. Treatment of the results

java.sql class

Connection:a session with a specific database;

Common methods: Statement createstatement ()

Statement:the object used for executing a static SQL Statement and returning the results it produces.

Common methods: ResultSet executeQuery (String sql)

This method is used to execute SQL query statements such as SELECT, returning a ResultSet object

int executeupdate (String sql)

This method can execute SQL query statements such as update DELETE INSERT, return an integer type, represent the number of rows changed, and return 0 for table changes;

RESULTSET:A table of data representing a database result set

Common methods: Boolean next ()

The resultset contains a pointer that initially points to the first row of the query result, and moves downward through the next () function until the result is null to return False

int getInt (String str)

Gets the integer number of the field STR, similar to the function string getString (String str)

JDBC and java.sql

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.