give me a java code snippet to connect Microsoft excel
through.... I am trying alot... plz help me.
Answer Posted / amar
import java.util.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class Connect extends HttpServlet
{
public void service(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
Connection con=null;
Statement st=null;
PreparedStatement pst=null;
ResultSet rs;
try
{
Class.forName
("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection
("jdbc:odbc:Std","","");
st=con.createStatement();
rs=st.executeQuery("select * from
[ExcelSheetName$]");
while(rs.next())
{
out.println(rs.getString
(1));
out.println(rs.getString
(2));
out.println(rs.getString
(3));
}
}
catch(Exception e)
{
System.out.println("Errr :"+e);
}
}
}
| Is This Answer Correct ? | 4 Yes | 4 No |
Post New Answer View All Answers
What is odbc and jdbc?
Name the new features added in jdbc 4.0.
Compare jdbc and odbc and how is jdbc required in this context.
How to set the attribute concurrency in resultset?
What does the jdbc connection interface?
Why resultset is used in java?
Differentiate between type_scroll_insensitive and type_scroll_sensitive.
What is the role of the jdbc drivermanager class?
Result set’s index starts with 0 or 1?
What is a jdbctemplate?
What protocol does jdbc use?
What do you mean by database connection pooling?
What does the jdbc resultsetmetadata interface?
Explain about DSN?
What is meant by jdbc and odbc?