Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.Connection;
- import java.sql.Statement;
- import java.sql.ResultSet;
- import java.sql.DriverManager;
- public class ExcelReader {
- public static void main( String [] args ) {
- Connection c = null; Statement stmnt = null;
- try
- {
- Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
- //using DSN connection. Here qa is the name of DSN
- //c = DriverManager.getConnection( "jdbc:odbc:qa", "", "" );
- //using DSN-less connection
- c = DriverManager.getConnection( "jdbc:odbc:Driver={Microsoft Excel Driver (*.xls)};DBQ=C:/Users/Μιχάλης/Documents/mike1.xls");
- stmnt = c.createStatement();
- String query = "select * from [Ledis$] ;";
- ResultSet rs = stmnt.executeQuery( query );
- while( rs.next() )
- {
- System.out.println(rs.getString(1));
- }
- }
- catch( Exception e )
- {
- //System.err.println( e );
- }
- finally
- {
- try
- {
- stmnt.close();
- c.close();
- }
- catch( Exception e )
- {
- System.err.println( e );
- }
- }
- }
- }
- 90-02-00-0000-2000
- 90-02-00-0000-2400
- 90-02-00-0000-2500
- 90-02-00-0000
- 90-02-00
- 90-02
- 90-06-00-0000-6000
- 90-06-00-0000-6100
- 90-06-00-0000-6200
- 90-06-00-0000-6300
- 90-06-00-0000-6400
- 90-06-00-0000-6500
- 90-06-00-0000-6600
- 90-06-00-0000
- 90-06-00
- 90-06
- null
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement