
hello!!!!.
i have a Excel file which includes 4 columns and somewhat 8500 rows.these rows i have printed in SQL thru Excel file and i have 1 MYSql database which includes all those 4 fields i have defined in excel file and i want dat 4 fields to b filled wid dat Excle file fields which will come out from java output so how to do all dis!!!???

Follow these steps:
1)Go to the start<<Control Panel<<Administrative Tools<< data sources.
2)Click Add button and select the Driver do Microsoft Excel(*.xls).
3)After selecting the driver, click finish button.
4)Then give Data Source Name,select drive, directory and excel file and click ok button.
5)Your DSN will get created.
6)Click ok button.
7)Then compile the following code:
import java.sql.*;
public class ReadExcelFile {
public static void main(String[] args) {
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:excel");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("select * from [sheet$]");
Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
Statement st=conn.createStatement();
while (rs.next()){
st.executeUpdate("insert into student(firstname,lastname,email,address) values('"+rs.getString(1)+"','"+rs.getString(2)+"','"+rs.getString(3)+"','"+rs.getString(4)+"')");
}
System.out.println("Data has been read from the excel file and inserted into the database.");
}
catch(Exception e){
System.out.println(e);
}
}
}
In the above code 'sheet' is the name of our worksheet that we have specified in our selected excel file. So you have to specify the sheet name of your selected sheet.
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.