
iam getting data but column names are not displaying

<%@page import="java.sql.*"%>
<table border=1>
<tr>
<%
try{
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select * from employee");
ResultSetMetaData rsmd = rs.getMetaData();
int numColumns = rsmd.getColumnCount();
for (int i=1; i<numColumns+1; i++) {
String columnName = rsmd.getColumnName(i);
%>
<th><%=columnName%></th>
<%
}
%>
</tr>
<%
while(rs.next()){
%>
<tr>
<%
for (int i = 1; i <= numColumns; i++){
%>
<td><%=rs.getObject(i)%></td>
<%
}
%>
</tr>
<%
}
rs.close();
st.close();
con.close();
}
catch(Exception e){}
%>
</table>
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.