Tuesday, July 24, 2012

creating database table by using jdbc


//Table creation
import java.sql.*;
import java.io.*;

public class JdbcDemo
{
            public static void main(String args[]) throws Exception
            {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");//Type1
            Connection con=DriverManager.getConnection("jdbc:odbc:das","scott","tiger");
            Statement st=con.createStatement();
            int i=st.executeUpdate("create table employee4(eno number(10),ename varchar2(50), esal
             number(10))");
            System.out.println(i);
                        if(i==-1)
                        {
                                    System.out.println("Table created");
                        }
                        else
                        {
                                    System.out.println("Table not created.");
                        }
                        st.close();
                        con.close();
            }
}

No comments:

Post a Comment