import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class Test {
public static void main(String[] args) throws SQLException {
Statement stmt = null;
ResultSet rs = null;
Connection con = null;
String serialNo ="";
try {
Class.forName("com.hxtt.sql.excel.ExcelDriver");
con = DriverManager.getConnection("jdbc:excel:/c:/temp/Layout.xls?WRITE=true","", "");
stmt = con.createStatement();
String excelQuery = "select * from [Sheet1$]";
rs = stmt.executeQuery(excelQuery);
while (rs.next()) {
serialNo = String.valueOf(rs.getInt(1));
System.out.println(serialNo);
}
}
catch (Exception e) {
e.printStackTrace();
}
finally {
try {
rs.close();
stmt.close();
con.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
//Note : Jar required : Excel_JDBC30.jar
No comments:
Post a Comment