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
Post a Comment