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
Which database is used for java?
Is jdbc faster than hibernate?
Write a program JDBCcode forfetching student database with SQL.
What is executeupdate in java?
Differentiate between type_scroll_insensitive and type_scroll_sensitive.
Explain the life cycle of jdbc.
Define preparedstatement.
What is the execute method in java?
What are different types of JDBC Drivers?
What is a jdbc driver and how many jdbc drivers are available?
How to move the cursor in scrollable resultset ?
What are the different types of statements in jdbc?
Is jdbc object oriented?
Name different methods for getting streams.
Describe odbc?