package com.javastuff.jdbc;
import java.sql.*;
/**
* @author Javastuff
*/
public class GetExcelSheetData {
public static void main(String args[])throws SQLException, ClassNotFoundException
{
Driver d= (Driver) (Class.forName((String)p.get("driver")).newInstance());
Connection con = d.connect( "jdbc:oracle:thin:@localhost:1521:java","scott","tiger"); Statement st=con.createStatement();
String query = "select * from [Sheet1$]";
ResultSet rs=st.executeQuery(query);
System.out.println ("COL1\tCOL2\tCOL3:");
while (rs.next()){
System.out.print (rs.getInt(1)+ "\t");
System.out.print(rs.getString("col2")+ "\t");
System.out.println (rs.getDouble("col3"));
}//while
}//main
Note :To execute the following example you can replace username and password with your actual user name and password.
Posted in: