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