Database Connection

 class DbConnection

{

    {    

        Connection con=DriverManager.getConnection("jdbc:postgresql://"+hostname+":"+port+"/"+dbname, username, password);

        Statement stmt=con.createStatement();

        ResultSet rs=stmt.executeQuery("select * from students where id=123456");

        while(rs.next())

        {

             System.out.println(rs.getString(1));

        }

    }

    catch(SQLException e)

    {

        e.printStackTrash();    

    }

}

Comments

Popular posts from this blog

Run Selenium Tests on Chrome Browser

Collection Framework

Emulate Chrome Browser into mobile View by Using Selenium part-1