INSERT STATEMENTS

1 package jdbcapplication;
 2 
 3 import java.sql.*;
 4 public class insert1
 5 {
 6     Connection conn;
 7     Statement st;
 8     String qr;
 9     String driver,url;
10     public insert1()
11     {
12         driver="com.mysql.jdbc.Driver";
13         url="jdbc:mysql://localhost/bhupesh";
14         qr="insert into emp(eid,ename,esal,ejob) values(101,'mohan',5000,'sprt')";
15          System.out.println(qr);
16         try
17         {
18         conn=DriverManager.getConnection
(url,"root","ashok");
19         st=conn.createStatement();
20         st.execute(qr);
21         System.out.println("INSERTION DONE..!!");
22         conn.close();
23         }
24         catch(Exception e)
25         {
26             System.out.println("Error : "+e.getMessage());
27         }
28      
29     }
30     public static void main(String args[])
31     {
32         insert1 obj=new insert1();
33     }
34 }                      


No comments:

Post a Comment