Drop Down

Tuesday, April 9, 2019

Create Table

package jdbc;

import java.sql.*;
import java.sql.Statement;

public class CreateTableDemo
{
public static void main(String[] args) throws SQLException, ClassNotFoundException
{ try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","hr", "hr");
Statement st = con.createStatement();
st.executeUpdate("create table demo(d_num number , d_name varchar2(10), d_rate number)");
//st.executeQuery("commit");
System.out.println("Table created");
con.close();
}
catch(SQLException e)
{
System.out.println(e);
}
catch(ClassNotFoundException e2)
{
System.out.println(e2);
}
}
}

No comments:

Post a Comment

Java 8 Notes Pics