I am new to R and want to import an Excel file into SQL Server. Each time,read 1 row and insert 1 row using sqlQuery(as I worry about some big excel sheet in the future). Only after 7 rows inserted and the error pops up and keeps coming during later re-runs(increased the Jave memory to 2G but no difference).
Is there somebody know this and please kindly point out the problem with my coding style or synatax? Much appreciate for your reply:)
> library(xlsx)
Loading required package: xlsxjars
Loading required package: rJava
> .jinit(parameters="-Xmx2g")
[1] 0
> for(i in 1:100 ){
+ Res <- read.xlsx(file="D:/mingdong/R/SECM.xlsx",sheetIndex=1,startRow=i, endRow=i+1,colIndex =1:4,stringsAsFactors=FALSE,encoding="UTF-8")
+ print(paste(Res)) }
[1] "000000" "1" "A360" "1000"
[1] "000001" "1" "A360" "1000"
[1] "000002" "1" "A360" "1000"
[1] "000003" "1" "A360" "1000"
[1] "000004" "1" "A360" "1000"
[1] "000005" "1" "A360" "1000"
[1] "000006" "1" "A360" "1000"
[1] "000007" "1" "A360" "1000"
Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl, :
java.lang.OutOfMemoryError: Java heap space
>