import java.io.*;
import java.sql.*;
public class dk
{
public static void main(String[] args)throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String rno,name,dept,mark;
System.out.println("enter the value(rno,name,mark,dept)to be inserted");
rno=br.readLine();
name=br.readLine();
mark=br.readLine();
dept=br.readLine();
int r1no=Integer.parseInt(rno);
int mark1=Integer.parseInt(mark);
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:krmicro","scott","tiger");
PreparedStatement st=con.prepareStatement("insert into newtable values(?,?,?,?)");
st.setInt(1,r1no);
st.setString(2,name);
st.setInt(3,mark1);
st.setString(4,dept);
st.executeUpdate();
}
catch(Exception e)
{
System.out.println(e);
}
}
}
↧