Java Design Pattern
Introduction to Java 10
Introduction to Java 11
Introduction to Java 12

JDBC Create a Table

Example;
JdbcExample1.java
package java8s;
import java.sql.*;
public class JdbcExample1 {
    public static void  main(String[] args) throws Exception{
        Class.forName("oracle.jdbc.driver.OracleDriver");
        Connection  con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","oracle");
        Statement  st=con.createStatement(); 
String s= "create table customer(" + "C_ID NUMBER(5) NOT NULL, " + "CNAME VARCHAR(100) NOT NULL, " + "Caddress VARCHAR(200) NOT NULL, " + "Creport_DATE DATE NOT NULL, " + "PRIMARY KEY (C_ID) " + ")"; System.out.println(s); st.execute(s); System.out.println("table is created"); } }
Output

create table customer1(C_ID NUMBER(5) NOT NULL, C_NAME VARCHAR(20) NOT NULL, C_add VARCHAR(20) NOT NULL, C_DATE DATE NOT NULL, PRIMARY KEY (C_ID) )
table is created


About the Author



Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.


We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc







 Previous