Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package college;
- import java.sql.*;
- public class College {
- public static void main(String[] args) {
- // TODO code application logic here
- Connection con;
- PreparedStatement pstmt;
- try
- {
- Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
- con=DriverManager.getConnection("jdbc:odbc:Aakarshap");
- pstmt=con.prepareStatement("Select eName from Employee where eNum=?");
- pstmt.setString(1, args[0]);
- ResultSet rst=pstmt.executeQuery();
- if(rst != null)
- while(rst.next())
- {
- System.out.println(rst.getString("eName"));
- }
- else
- System.out.println("No record found");
- }
- catch(ClassNotFoundException ce)
- {
- System.out.println("Error"+ce);
- }
- catch(SQLException se)
- {
- System.out.println("Error"+se);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment