Final Database
Final Database
Final Database
import java.sql.*; class Connect { public static void main(String s[]) { Connection co=null; try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); co=DriverManager.getConnection("Jdbc:Odbc:abi"," ", " "); System.out.println("Connection successful"); co.close(); } catch(Exception e) { System.out.println(" "+e); } } }
Connect1.java
import java.sql.*; class Connect1 { public static void main(String s[]) { Connection co=null; try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); co=DriverManager.getConnection("Jdbc:Odbc:abi"," ", " "); Statement st=co.createStatement(); int res=st.executeUpdate("create table db(name varchar(20),rollno varchar(20),dept varchar(20),year varchar(5),percentage varchar(5))"); System.out .println("Table Created"); st.close(); co.close(); } catch(Exception e) { System.out.println(" "+e); } }}
Connect2.java
import java.sql.*; class Connect2 { public static void main(String s[]) { Connection co=null; String s1=s[0]; String s2=s[1]; String s3=s[2]; String s4=s[3]; String s5=s[4]; try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); co=DriverManager.getConnection("Jdbc:Odbc:abi"," ", " "); Statement st=co.createStatement(); int result=st.executeUpdate("insert into db values('"+s1+"','"+s2+"','"+s3+"','"+s4+"','"+s5+"')"); System.out .println("values inserted in the table"); st.close(); co.close(); } catch(Exception e) { System.out.println(" "+e);
} } }
OUTPUT