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 the meaning of connection?
What is layer in communication?
Is jdbc a middleware?
What is the difference between jdbc and odbc?
What is 2 phase commit?
How many types of jdbc drivers are there?
Is jdbc an api?
What are the different types of JDBC drivers?
What is jndi lookup?
DB2 Universal claims to support JDBC 2.0, But I can only get JDBC 1.0 functionality. What can I do?
What are the different types of resultset?
Explain how to make updates to the updatable resultsets.
What is a java driver?
Why did my jdbc code throw a rollback sqlexception?
How many packages are available in jdbc api?