JDBC database connection and addition, deletion, modification, and query operations

Source: Internet
Author: User

What is JDBC?
Java is a set of APIs to access databases.
JDBC (Java Database Connectivity) APIs, Java Database programming interfaces, are interfaces and classes in a set of standard Java languages, using these interfaces and classes, java client programs can access different types of databases. For example, you can establish a database connection and execute SQL statements to access data.

The JDBC specification adopts the idea of interface and implementation separation to design the Java database programming framework. Interfaces are included in the java. SQL and javax. SQL packages. java. SQL belongs to JavaSE and javax. SQL belongs to JavaEE. The implementation classes of these interfaces are called database drivers, which are provided by the database vendor or other vendor or individual.

To make the client program independent from a specific database driver, we recommend that developers use an interface-based programming method in the JDBC specification, that is, to make the application only dependent on java. SQL and javax. SQL interfaces and classes.

< strong>

< strong>

< strong>

< strong>

< strong>

< strong>

< strong>

< strong>

< p>

< p>

< p>

< p>

< p>

Class. forName ("oracle. jdbc. oracleDriver "Connection conn = DriverManager. getConnection ("jdbc: oracle: thin :@ localhost: 1521: ORCL", "wladmin", "lan2711" System. out. println ("connection successful" PreparedStatement pStat = conn. prepareStatement ("insert into testresult values (003, 'jdbc ')" System. out. println ("inserted successfully" pStat = conn. prepareStatement ("select * from testresult" ResultSet rs = System. out. println (rs. getInt (1) + "" + rs. getString (2 }}}

 

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.