After the Java database is connected, the database is

Source: Internet
Author: User

Method of Use: Statement

Additions and Deletions: Method: Execute (String SQL)

String url= "Jdbc:access:///e://a//shop.mdb";

Connection con=null; //Database Connection object

    Statement st = null; Database Operations Object

   SQL statements

    String SQL= "INSERT into goods values (' 7 ', ' Ghost king ', ' Male ', ' ghost Wang Zong ', ' Dragon Tripod ')";

String sql= "UPDATE goods set gate = ' Tsing Yun gate ' where name = ' Zhang Xiao van '";

Class. forname ("Com.hxtt.sql.access.AccessDriver");

Con = DriverManager. getconnection (URL, "", "");

System. out. println ("Connection succeeded");

   Create an Action object for the database

   st=con.createstatement (); //function to connect the database connection object to the database Operation object

    st.execute (SQL); //This method is used to execute the INSERT update DELETE statement

System. out. println ("insert operation succeeded");

Find: Method: ExecuteQuery (String SQL) returnsResultSetObject

String url= "Jdbc:access:///e://a//shop.mdb";

Connection con=null;

   Statement st = null; //object that executes the query

    String sql= "SELECT * from goods";

Class. forname ("Com.hxtt.sql.access.AccessDriver");

Con = DriverManager. getconnection (URL, "", "");

System. out. println ("Connection succeeded");

    st = Con.createstatement (); //Create query Object

   ResultSet rs;

rs = st.executequery (sql); //Executes the query statement and returns a result

The results of the query appear as pointers, pointing to the first record, and viewing the results by moving the pointer

     while (Rs.next ()) {//Read query results sequentially by Loop

Database access-related indexes are all starting from 1

System. Out. println (rs.getstring (2) + ":" +rs.getstring (3) + ":" +rs.getstring (4));

}

After the Java database is connected, the database is

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.