filmov
tv
How to Export data from oracle to excel in java

Показать описание
Required Softwares:-
Java Code :
package demo1;
/**
*
* @author TechnoStudio
*/
public class Demo1 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
try{
//step1 load the driver class
//step2 create the connection object
//step3 create the statement object
//step4 execute query
//Blank workbook
XSSFWorkbook workbook = null;
//Create a blank sheet
XSSFSheet sheet = null;
//This data needs to be written (Object[])
XSSFRow row = null;
XSSFCell cell;
int existingRows = 0;
FileInputStream fsIP = null;
//Read the spreadsheet that needs to be updated
fsIP = new FileInputStream(targetFile);
workbook = new XSSFWorkbook(fsIP);
existingRows++;
} else {
workbook = new XSSFWorkbook();
existingRows++;
}
//step6 Update Database
existingRows++;
}
if(fsIP != null) {
fsIP.close();
}
//step5 close the connection object
} catch(Exception e) {
}
}
}
Java Code :
package demo1;
/**
*
* @author TechnoStudio
*/
public class Demo1 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
try{
//step1 load the driver class
//step2 create the connection object
//step3 create the statement object
//step4 execute query
//Blank workbook
XSSFWorkbook workbook = null;
//Create a blank sheet
XSSFSheet sheet = null;
//This data needs to be written (Object[])
XSSFRow row = null;
XSSFCell cell;
int existingRows = 0;
FileInputStream fsIP = null;
//Read the spreadsheet that needs to be updated
fsIP = new FileInputStream(targetFile);
workbook = new XSSFWorkbook(fsIP);
existingRows++;
} else {
workbook = new XSSFWorkbook();
existingRows++;
}
//step6 Update Database
existingRows++;
}
if(fsIP != null) {
fsIP.close();
}
//step5 close the connection object
} catch(Exception e) {
}
}
}
Комментарии