This content has been marked as final.
Show 1 reply
-
1. Re: Coonection in jasper report
imran.imran_lk2002.yahoo.com Jul 28, 2009 9:33 AM (in response to pmsudha)public class DataSourceService {
private Connection con =null;
public DataSourceService() { }
public DataSource getDataSource() throws NamingException, SQLException {
InitialContext ic = new InitialContext();
DataSource ds = (DataSource) ic.lookup("java:/crsDatasource");
System.out.println("Getting datasource...."+ds);
return ds;
}
public Connection getConnection() throws Exception {
DataSource ds = this.getDataSource();
try {
con = ds.getConnection();
} catch (Exception e) {
System.out.println(e.getMessage());
}
return con;
}
}
----------------------------------------------------+++---------
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
Connection connection=null;
OutputStream ouputStream = response.getOutputStream();
try {
try {
connection = d.getConnection();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
.........