JDBC application For Dropping table
For Explanation Watch Video:::
Before Execution Of code::
SQL> desc test2;
Name Null? Type
----------------------------------------- -------- ----------------------------
EID NUMBER(38)
ENAME VARCHAR2(10)
Code:::
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.*;
public class College {
public static void main(String[] args)throws Exception{
Connection con =
DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","system","tiger");
Statement st = con.createStatement();
//query
String query = "drop table test2";
//execute the query
int count = st.executeUpdate(query);
if(count==0){
System.out.println("Table is dropped");
}else{
System.out.println("Table is not dropped");
}
con.close();
}
}
After Execution Of code::
SQL> desc test2;
ERROR:
ORA-04043: object test2 does not exist
Comments
Post a Comment