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
What does the jdbc connection interface?
What is drivermanager in jdbc?
What do you mean by metadata and why we are using it?
Which type of JDBC driver is the fastest one?
How to insert and delete a row programmatically? (new feature in JDBC 2.0)
How to check jdbc driver version in sql server?
How can you load the drivers?
What is setautocommit in jdbc?
Explain Basic Steps in Writing a Java Program Using Jdbc?
Differentiate between type_scroll_insensitive and type_scroll_sensitive.
Is jdbctemplate thread safe?
Does JDBC support stored procedures?
What is the latest version of JDBC? What are the new features added in that?
Differentiate between a statement and a preparedstatement.
What are the different types of locking in JDBC?