return (DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","netbank","netbank")); } catch (Exception exp) { return null;} } public void doGet(HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException { PrintWriter out=res.getWriter(); String repttype=req.getParameter("table").replace('_',' '); out.println("
"+repttype+"
"); generateReports(req,res); } public void doPost(HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException{ PrintWriter out=res.getWriter(); String repttype=req.getParameter("table").replace('_',' '); out.println(""+repttype+"
"); generateReports(req,res); } public void getQueryToParse(String vall,HttpServletResponse res) throws ServletException,IOException { PrintWriter out=res.getWriter(); try { String ds; int iv; String data="Select * from "+vall; Connection conn=null; Statement st=null; PreparedStatement pst=null; ResultSet rs=null; ResultSetMetaData meta=null; conn=getConnection(); st=(conn!=null)?conn.createStatement():null; rs=(st!=null)?st.executeQuery(data):null; meta=(rs!=null)?rs.getMetaData():null; int ct=0; out.println(""); out.println("Reports Generation"); out.println(""+meta.getColumnName(mt).replace('_','-')+" | "); out.println("");} while(rs!=null && rs.next()) { ct++;out.println("||
---|---|---|
"+ds+" | ");} else if(metaname.indexOf("date")!=-1) { ds=rs.getDate(d).toString(); out.println(""+ds+" | ");} else { iv=rs.getInt(d); out.println(""+iv+" | ");} } out.println("
Print The Reports
"); } catch (Exception e) { out.println("Error Occured
"+e); } } public void generateReports(HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException { getQueryToParse(req.getParameter("table"),res); }}
No comments:
Post a Comment