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 is a jdbc connection?
What is jdbc url for mysql?
What are the packages are used in jdbc?
What are the main components of JDBC ?
What are jdbc?
How many types of jdbc drivers are available?
password, is stored in as plain text. What can I do to protect my passwords?
What is JDBC Transaction Management and why do we need it?
Is jdbc a framework?
Under what circumstances, that all four drivers are used?
What are types of resultset?
Describe the steps needed to execute a sql query using jdbc.
Why is jdbc needed?
Can resultset be null in java?
What is database connection pooling? Advantages of using a connection pool?