//Creating a Table using java programe
import java.sql.*;
public class Table_create
{
public static void main(String args[])
{
try
{
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
System.out.println("thin driver is registerd");
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","system");
System.out.println("Connection is established to DB");
Statement stmt=con.createStatement();
System.out.println("Statement object is created");
stmt.executeUpdate("create table student(sno number(5),name varchar2(10),place varchar2(10))");
System.out.println("Table is crated -------> ");
}
catch(Exception e)
{
e.printStackTrace();
System.out.println("Registeration faild");
}
}
}
/*
Explanation:
Here we are used a method "executeUpdate()" it takes one parameter
as argument i.e SQL Query
*/
No comments:
Post a Comment