Create Table in Java DB JDBC Concepts. This Java Create Table DB (database) example describes the basic operations performed on the JDBC create table database connectivity code.In this example you will learn about how to write java code create database table with oracle database.
Program:
import java.sql.*;
public class CreateTable {
public static void main(String args[]){
Connection con=null;
Statement st = null;
try {
Class.forName(“oracle.jdbc.driver.OracleDriver”);
con=DriverManager.getConnection(“jdbc:oracle:thin:@localhost:1521:ORCL”,”scott”,”tiger”);
st = con.createStatement();
boolean c =st.execute(“create table eshusoft(username varchar2(20) ,password varchar2(20))”);
System.out.print(“Table eshusoft is created “);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Result:
Table eshusoft is created