Commit e3942b49 by Mihailo Sebek

komentar repository dodate funkcije

parent beca7ae7
...@@ -81,4 +81,42 @@ public class KomentarRepository { ...@@ -81,4 +81,42 @@ public class KomentarRepository {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }
public double averageOcenaByOglasId(int oglasId)
{
String sql = "{call averageOcenaByOglasId(?)}";
ResultSet rs=null;
CallableStatement stmt = null;
try {
stmt = dataBase.connection.prepareCall(sql);
stmt.setInt(1,oglasId);
rs=stmt.executeQuery();
while(rs.next())
{
return rs.getDouble(1);
}
} catch (SQLException e) {
throw new RuntimeException(e);
}
return 0;
}
public double averageOcenaByKorisnikId(int korisnikId)
{
String sql = "{call averageOcenaByKorisnikId(?)}";
ResultSet rs=null;
CallableStatement stmt = null;
try {
stmt = dataBase.connection.prepareCall(sql);
stmt.setInt(1,korisnikId);
rs=stmt.executeQuery();
while(rs.next())
{
return rs.getDouble(1);
}
} catch (SQLException e) {
throw new RuntimeException(e);
}
return 0;
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment