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 are the main steps in java to make JDBC connectivity?

573


Which database is used with java?

497


What are the three basic components of the odbc architecture?

469


Discuss the procedure of retrieving warnings?

560


Is jdbc a middleware?

505






What is difference between jdbc and odbc?

494


How java can be connected to a database?

567


Explain about the Try Block?

557


How to invoke Oracle Stored Procedure with Database Objects as IN/OUT?

582


There is a method getColumnCount in the JDBC API. Is there a similar method to find the number of rows in a result set?

617


What are the advantages of database connection pooling?

489


Is jdbctemplate thread safe?

484


How can you make a connection?

534


What are the differences between resultset and rowset?

527


What are the advantages of using preparedstatement in java?

548