title: Context.xml way for get connection
body: <p>Im trying to make connection in my java code with the database, using context.xml file and my code is as follows,</p>
  
  <pre><code> InitialContext ic = new InitialContext();
      Context xmlContext = (Context) ic.lookup("java:comp/env"); 
      DataSource myDatasource = (DataSource) ((InitialContext)
  xmlContext).lookup("jdbc/MyDatasource");
  
  
      con = myDatasource.getConnection();
  </code></pre>
  
  <p>But im getting error on last line (con=myDataSource.getConnection();) stating add cast to myDataSource..m not able to resolve this..any help??   My imports are as follows</p>
  
  <pre><code>import java.io.File;
  import java.sql.Connection;
  import java.sql.PreparedStatement;
  import java.sql.ResultSet;
  import java.sql.SQLException;
  import java.text.DecimalFormat;
  import java.text.SimpleDateFormat;
  import java.util.Date;
  import java.util.Locale;
  
  
  import com.lowagie.text.pdf.codec.postscript.ParseException;
  </code></pre>