public void insertNewFact(String name, String text) {
        PreparedStatement ps = null;
        
        try{
            stat.setQueryTimeout(30);
            ResultSet rs = stat.executeQuery("Select * from Fact " +
"where Name = '"+name+"' OR Text ='"+text+"'");
           
            if(!rs.isBeforeFirst())
            {
                //add new fact to database
                String sql = "INSERT INTO Fact (Name, Text, Counter, AnswerFlag, Image) " +
                   "VALUES ('"+name+"', '"+text+"', 0, 0,'')";
            stat.executeUpdate(sql);
            }
            else
            {
                stat.setQueryTimeout(30);
                //increase counter of the current fact
                int Factid = rs.getInt("Id");
                int count = rs.getInt("Counter");
                if(count != -1)
                {
                    String sql = "UPDATE Fact Set Counter ="+(++count)+" where Id ="+Factid;
                    stat.execute(sql);
                }
            
            }
        }catch(Exception e){
            System.out.println("insert fact failed");
            System.out.println(e.getMessage());
        }
    }