import java.io.BufferedReader;
import java.sql.Connection;
import java.sql.DriverManager;
public class JdbcApp02
{
public static void main(String[] args)throws Exception
{
Class.forName("oracle.jdbc.OracleDriver");
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","Rajat709$");
Statement st=con.createStatement();
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter Table Name : ");
String tname=br.readLine();
String query="create table "+tname+"(ENO number(4) primary key,ENAME varchar2(10),ESAL float(5),EADDR varchar2(10))";
st.executeUpdate(query);
System.out.println("Table "+tname+" is created successfully");
st.close();
con.close();
}
}
/*
ERROR:
JdbcApp02.java:14: error: cannot find symbol
Statement st=con.createStatement();
^
symbol: class Statement
location: class JdbcApp02
JdbcApp02.java:15: error: cannot find symbol
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
^
symbol: class InputStreamReader
location: class JdbcApp02
2 errors
*/