Hi
I want to create an html report based on a table named inventory on sql server 2005 database.
first code used to generate an output report
try {
// TODO add your handling code here:
String s = "<html> <body> <table border=1><caption> Inventory Report </caption>";
s += "<tr><td>Item_id<td>item_name<td>Existing quantity</td><tr><td>3<td>4<td> <td>";
byte[] sb = s.getBytes();
FileOutputStream fs = null;
try {
fs = new FileOutputStream("D:\\Report\\Report.html");
} catch (FileNotFoundException ex) {
Logger.getLogger(mileshframe.class.getName()).log(Level.SEVERE, null, ex);
}
fs.write(sb);
fs.close();
} catch (IOException ex) {
Logger.getLogger(mileshframe.class.getName()).log(Level.SEVERE, null, ex);
}
}
Second jdbc code for connection and select all records in the table
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:MerchandiseCon","sa","sql123#");
st = con.createStatement( );
ResultSet rset=st.executeQuery("Select Item_code,Item_Name,item_cost,item_quantity from Inventory");
String s="";
while(rset.next())
{
s+=(rset.getString(1)+"\t\t"+rset.getString(2)+"\t"+rset.getString(3)+"\t"+rset.getString(4)+"\n");
}
st.close();
con.close();
}
catch(ClassNotFoundException ex)
{
ex.printStackTrace();
}
catch(SQLException ex)
{
ex.printStackTrace();
}
}
I want someone helps me to mix the two codes into one code to generate an output html report.
thanks in advance