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
How do I insert an image file (or other raw data) into a database?
How can we set null value in jdbc preparedstatement?
How can I get information about foreign keys used in a table?
Explain the process of creating tables using NetBeans IDE?
Is jdbc database independent?
What is a jdbc connection pool?
If you are truncated using JDBC, how can you that how much data is truncated?
What are the differences between resultset and rowset?
What is jdbc thin client?
What is drivermanager in java?
What are four types of JDBC driver?
What is drivermanager in jdbc?
What is sqlwarning and discuss the procedure of retrieving warnings?
How can I create a custom RowSetMetaData object from scratch?
Can I use JDBC to execute non-standard features that my DBMS provides?