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


Please Help Members By Posting Answers For Below Questions

What do you mean by database connection pooling?

681


What is the benefit of having jdbcrowset implementation? Why do we need a jdbcrowset like wrapper around resultset?

683


What is jdbc drivers in java?

640


When do we get java.sql.SQLException: No suitable driver found?

730


What is jdbc architecture?

708


What are the differences between statement and preparedstatement interface?

710


How can you retrieve data from the resultset using jdbc?

720


What does connection pooling mean ?

738


What is JDBC Driver interface?

755


What is Apache DBCP API?

746


What does adapter class provide?

677


What is jdbc resultsetmetadata interface?

701


What isolation level is used by the DBMS when inserting, updating and selecting rows from a database?

692


How to set NULL values in JDBC PreparedStatement?

713


How are jdbc statements used?

680