Creating table Using JDBC Application
For Explanation Watch Video:
EX1::
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 Test1 {
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 = "create table test2(eid int,ename varchar2(10))";
//execute the query
int count = st.executeUpdate(query);
if(count==0){
System.out.println("Table is created");
}else{
System.out.println("Table is not created");
}
con.close();
}
}
After Execution Of Program
Table::
SQL> desc test2;
Name Null? Type
----------------------------------------- -------- ----------------------------
EID NUMBER(38)
ENAME VARCHAR2(10)
Comments
Post a Comment