JDBC program for truncate table
for explanation watch video::
Before Execution Of Program::
SQL> select * from test1;
EID ENAME
---------- ----------
1 raja
2 Jhon
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();
//write query
String query = "truncate table test1";
//execute
int count = st.executeUpdate(query);
if(count==0){
System.out.println("Table is truncated");
}else{
System.out.println("Table is not truncated");
}
con.close();
}
}
After Execution of Program::
======================
SQL> select * from test1;
no rows selected
Comments
Post a Comment