give me a java code snippet to connect Microsoft excel
through.... I am trying alot... plz help me.
Answer Posted / n.gowtham raj
import java.io.*;
import java.net.*;
import java.sql.*;
import java.util.*;
public class EmployeeReader1 {
public static void main(String[] args) {
Connection connection = null;
try {
Class.forName
("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con =
DriverManager.getConnection("jdbc:odbc:gowtham");
Statement st = con.createStatement
();
ResultSet rs = st.executeQuery
("select * from [Sheet1$]");
while(rs.next())
{
System.out.println
("USER ID:"+rs.getString("ID"));
}
rs.close();
st.close();
} catch (Exception ex) {
System.err.print("Exception: ");
System.err.println(ex.getMessage());
}
}
}
Step 1: goto control panel and select the Administrative
Tools and click the odbc driver.
Step 2: Then click the add button and select the microsoft
excel driver (".xls")
Step 3: then give the dsn name. (gowtham).
Step 4: then click the select workbook button and choose
the excel file then it work well.
| Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
How can I manage special characters when I execute an insert query?
How to test jdbc connection to sql server?
How many ways can you update a result set?
How to achieve JDBC Connection Pooling using JDBC DataSource and JNDI in Apache Tomcat Server?
What is jdbc and jdbc drivers?
Does jdbc use odbc?
What are the steps required to execute a query in jdbc?
How can I connect mysql or oracle with java?
Is uri the same as url?
What is encrypted connection?
Explain what should be done when a SQL exception is raised?
Is jdbc an api?
What are temp tables ?
Does jpa use jdbc?
Explain the process of creating tables using NetBeans IDE?