Bookmark Topic Watch Topic
  • New Topic

JSP

 
Ganapathy palanisamy
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Report post to moderator
[size=12]hai friends,
I am doing the program for reading the data from excel.
import java.io.*;
import java.sql.*;
public class ExcelReadTest{
public static void main(String[] args){
Connection connection = null;
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection( "jdbc:odbc:emp" );
Statement st = con.createStatement();
ResultSet rs = st.executeQuery( "Select * from [Sheet1$]" );

ResultSetMetaData rsmd = rs.getMetaData();
int numberOfColumns = rsmd.getColumnCount();

while (rs.next()) {
for (int i = 1; i <= numberOfColumns; i++) {
if (i > 1) System.out.print(", ");
String columnValue = rs.getString(i);
System.out.print(columnValue);
}
System.out.println("");
}

st.close();
con.close();
} catch(Exception ex) {
System.err.print("Exception: ");
System.err.println(ex.getMessage());
}
}
}
[/size]

in the above works well to retrieve the data from excel. But i want to select particular cell value.. i.e i want to select the column heading from excel.

guide me friends..
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64958
86
IntelliJ IDE Java jQuery Mac Mac OS X
 
    Bookmark Topic Watch Topic
  • New Topic