Get excelsheet
Upcoming SlideShare
Loading in...5
×
 

Get excelsheet

on

  • 309 views

 

Statistics

Views

Total Views
309
Views on SlideShare
302
Embed Views
7

Actions

Likes
0
Downloads
0
Comments
0

1 Embed 7

http://rajjdbc.blogspot.in 7

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Get excelsheet Get excelsheet Presentation Transcript

  • Click on Administrative tool
  • Click Oc)n DataSource (ODB
  • Click on Add button
  • Select MicrosoftExcel Driver (*.xls) from the Create new Data source dialog box, and click on Finish button
  • Enter dsn name(ex: rajdsn)
  • Selct workWork book button • enter
  • Click ok,ok,ok
  • • • • • • • • • • • • • • • • • • • • • • /*step1: create the data in excel sheet, and save (same folder). here i created: id, ename sal click->start->control panel->select administrative tool and then Data Sources (ODBC), TO OPEN ODBC Data Source Administrator dialog box */ import java.sql.*; public class GetExcelSheet { public static void main(String args[])throws SQLException, ClassNotFoundException { Connection con=prepareConnection(); Statement st=con.createStatement(); String query = "select * from [Sheet1$]"; ResultSet rs=st.executeQuery(query); System.out.println ("idt enametsal:"); while (rs.next()){ System.out.print (rs.getInt(1)+ "t"); System.out.print(rs.getString("ename")+ "t"); System.out.println (rs.getDouble("sal")); }//while }//main
  • • public static Connection prepareConnection()throws SQLException, ClassNotFoundException { • • • • • • • • /* D:jdbcprogwed>javac GetExcelSheet.java • • D:jdbcprogwed>set classpath=D:softwaresMySQLnewmysql-connector-java-5.1.1 8-bin.jar;.; • • D:jdbcprogwed>java GetExcelSheet */ String driverClassName="sun.jdbc.odbc.JdbcOdbcDriver"; String url="jdbc:odbc:rajdsn"; Class.forName(driverClassName); return DriverManager.getConnection(url); }//prepareConnection }//class