Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args) {
- try {
- Class.forName("org.postgresql.Driver");
- Connection con=DriverManager.getConnection("jdbc:postgresql://localhost:5432/dvdrental2","postgres","vibhug");
- System.out.println("Opened database successfully");
- Statement st=con.createStatement();
- ResultSet rs=st.executeQuery("select * from actor ");
- while(rs.next())
- {
- int actor_id = rs.getInt("actor_id");
- String first_name = rs.getString("first_name");
- int last_name = rs.getInt("last_name");
- System.out.println( "ID = " + actor_id );
- System.out.println( "fNAME = " + first_name );
- System.out.println( "AGE = " + last_name );
- System.out.println();
- }
- con.close();
- } catch (ClassNotFoundException | SQLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- System.out.println("operation done successfully!!!");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement