Write a java program to accept the rno of student as a command line arguement and display the record of student (SNo,SName,Per) on the screen.


import java.sql.*;

import java.io.*;

class search   

    {

     public static void main(String args[])

    {

     Connection conn=null;

    ResultSet rs=null;

try    {

     Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

    conn=DriverManager.getConnection("jdbc:odbc:my1dsn.dsn");

    Statement stmt=conn.createStatement();

    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

    System.out.println("Enter rollno you want to search");

     int rno=Integer.parseInt(br.readLine());

     rs=stmt.executeQuery("Select * from student where rno="+rno);

    System.out.println("Success");

    while(rs.next())

    {     System.out.println("Rollno:"+rs.getInt(1)+""+"Name:"+rs.getString(2)+""+"Per:"+rs.getInt(3));    }

    rs.close();

    stmt.close();

    conn.close();

    }

    catch(Exception e)

    {

    System.out.println(e.toString());

    }

    }

}
Write a java program to accept the rno of student as a command line arguement and display the record of student (SNo,SName,Per) on the screen. Write a java program to accept the rno of student as a command line arguement  and display the record of student (SNo,SName,Per) on the screen. Reviewed by on April 27, 2015 Rating: 5
Powered by Blogger.