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 are the classes and methods used for sending sql statements to database?
Describe how the jdbc application works.
What is connection pooling and why it is used?
Is jdbctemplate thread safe?
What is jdbc url for mysql?
How we can you use preparedstatement.
Does jdbctemplate close connection?
Is jdbc open source?
How can you know about drivers and database information ?
What is ODBC and JDBC? How do you connect the Database?
Does jdbc require oracle client?
What is sqlwarning?
What happens if connection is not closed in jdbc?
What does executequery return in java?
What is meant by dao?