创建表::
sql>创建表test1(eid int,ename varchar2(10));
创建的表。
sql>插入test1值(1,vijay);
创建1行。
sql>插入test1值(2,rajeshâ);
创建1行。
sql>从test1;
选择 *eid ename
-
1 Vijay
2 rajesh
sql>提示;
提交完成。
import java.sql.*;
class Test {
public static void main(String[] args) throws Exception {
//load JDBC driver
//get connection
Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl", "system", "tiger");
//create statement obj
Statement st = con.createStatement();
//prepare and execute query
String query = "delete from test1 where eid=2";
int count = st.executeUpdate(query);
if (count == 0) {
System.out.println("No Row is deleted");
} else {
System.out.println(count + "Row are deleted");
}
con.close();
}
}
代码执行后
sql>从test1;
选择 *eid ename
-
1 Vijay