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
Explain the role of driver in jdbc.
What is the difference between client and server database cursors?
What are the differences between statement and preparedstatement interface?
How can we execute stored procedures using callablestatement?
Define preparedstatement.
What causes no suitable driver error?
What are the common JDBC problems that you got and how do you solved them?
What is metadata in jdbc?
How can I connect mysql or oracle with java?
Which interface handles transaction management in jdbc?
What is the use of getGeneratedKeys() method in Statement?
Does the JDBC-ODBC Bridge work with Microsoft J++?
What are the different types of locking in JDBC?
What is sqlwarning?
What does the jdbc driver interface do?