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 transaction processing in jdbc?
Does the JDBC-ODBC Bridge work with Microsoft J++?
How do I start debugging problems related to the JDBC API?
What is jdbc class forname?
What are the different classes through which JDBC represents statements?
Which type of JDBC driver is the fastest one?
What is getconnection method in java?
What are the factors that the jdbc driver performance depends upon?
What is the JDBC syntax for using a literal or variable in a standard Statement?
What protocol does jdbc use?
Is uri the same as url?
Can I set up a connection pool with multiple user IDs? The single ID we are forced to use causes problems when debugging the DBMS.
How many packages are available in jdbc api?
How data can be inserted into long row column of database?
Why do we need jdbc api?