give me a java code snippet to connect Microsoft excel
through.... I am trying alot... plz help me.

Answer Posted / r.salimulla baba

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 ?    15 Yes 9 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What does the jdbc connection interface?

539


What is drivermanager in jdbc?

541


What do you mean by metadata and why we are using it?

565


Which type of JDBC driver is the fastest one?

573


How to insert and delete a row programmatically? (new feature in JDBC 2.0)

532






How to check jdbc driver version in sql server?

478


How can you load the drivers?

551


What is setautocommit in jdbc?

490


Explain Basic Steps in Writing a Java Program Using Jdbc?

597


Differentiate between type_scroll_insensitive and type_scroll_sensitive.

523


Is jdbctemplate thread safe?

484


Does JDBC support stored procedures?

560


What is the latest version of JDBC? What are the new features added in that?

522


Differentiate between a statement and a preparedstatement.

498


What are the different types of locking in JDBC?

569