i am working on java
this my code.i want to get the no.of records from database.
class Model{
public int records{
int count=0;
try{
Class.forName("org.postgresql.Driver");
con=DriverManager.getConnection("jdbc:postgresql://localhost:5432/samyu","samyu","samyu");
}catch(Exception e){
System.out.println(e.getMessage());
}//catch
try{
st=con.createStatement();
query="select count(*) from mail_details";
count=st.executeQuery(query); //here giving error
}catch(Exception e){
System.out.println(e.getMessage());
}
return count;
}
}//class
what is the solution for this.give reply.