Sunday, 21 October 2012

creating of a table in JAVA



import java.sql.*;
import java.util.*;
class Student
{

    public  static void main(String[] argv)
    {
        try
        {
            Scanner sc=new Scanner(System.in);
            String roll,name,dob;
             int tot,phno;

             Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            String database ="jdbc:odbc:eceDSN";
            Connection con = DriverManager.getConnection(database, "", "");
            System.out.println("Connected");
         
      
         
              String query="create table ECE (roll TEXT(20), name TEXT(20), tot TEXT(20),phno TEXT(20),  dob DATETIME, Primary Key (roll))";
              Statement st=con.createStatement();
              int result=st.executeUpdate(query);
              System.out.println("Table Is Created");
            
            
        }
        catch(Exception err)
        {
            System.out.println(err.getMessage());
        }
        //loading all the driver to the memory

    }
}

No comments:

Post a Comment

Tech N Science © 2013