SAI YEWALE

Generation

typingsThu, 01 Dec 2022

Develop a program to create employee table in database having two columns "emp_id" and "emp_name"in advanced java.

import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.sql.Statement; public class CreateTable { public static void main(String[] args) throws ClassNotFoundException, SQLException { //step1 load the driver class Class.forName("oracle.jdbc.driver.OracleDriver"); //step2 create the connection object Connection con=DriverManager.getConnection( "jdbc:oracle:thin:@localhost:1521:xe","system","oracle"); //step3 create the statement object Statement stmt=con.createStatement(); //step4 execute query stmt.executeUpdate("create table employee(emp_id int,emp_name varchar(20))"); System.out.println("table created"); //step5 close the connection object

Questions about programming?Chat with your personal AI assistant