title: Dblink is not working in java
body: <pre><code>String id="";
              List list = null;
              Query query = null;
              Session session = getSession();
  String sql = "select id from student@dblink s, location@dblink l where s.id in (select name from Employ where id='" +Id +"') and s.country_id = l.country_id and l.country_end = '"+countryEnd+"'";
              query = session.createSQLQuery(sql);
              System.out.println("sql.1."+sql);
              list = query.list();
              if(list.size()&gt;0)
                  id = list.get(0).toString();
              else
                  id= "0";
              System.out.println("Stage2Ubr Id is:"+id);
              return id;
  </code></pre>
  
  <p>Here I got exception like "org.hibernate.exception.GenericJDBCException: could not execute query". Sometimes this exception is not coming. Sometimes it's working fine without exception. This exception won't come if dblink is working fine.Please help me. How to check wheather the dblink is working fine or not?</p>