❮ Previous

Create a Table

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



❮ Previous


Follow Us



  Tutorials

Popular Links

Contact Us

address Plot No-741,2ND Floor
Opp. Bhagabati Temple,Jayadev Vihar
      Bhubaneswar-751013
      Email: info@silantechnology.com
      Phone: 0674-2361252
address
39877, sundale dr, apt#101, Fremont, California 94538, USA
       Phone: +1(262)388-7619

facebook twitter google linked in

© 2018 Silan Technology. All Rights Reserved