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