# Java Heap Space Error on data insertion over SQL Server

I'm trying to insert 2-milliion lines into a SQL Database, and get this error:

JDBC::error: Java heap space

The insert is a standart Mathematica SQL statement:

conn = myConn[ip]
columns = {"Col1", "Col2", "Col3", "Col4"}
SQLInsert[conn, "MyTable", columns,data]
CloseSQLConnection[conn]


Where data is a Listof 2-million elements (rows). The command works just fine for a smaller number of rows.

I know I could break data into small chunks, but I would like to know how to solve it increasing the Java heap space.

-
Like this... support.wolfram.com/kb/3791 ? – Oleksandr R. Dec 30 '13 at 1:11
@OleksandrR. interesting tks. Do you know how can I know my current heap space? – Murta Dec 30 '13 at 1:22
@Murta Yes, you can call JavaLink[] and then you see in my case -Xmx256m which defines the maximum possible. – halirutan Dec 30 '13 at 1:43
@halirutan strange, when I execute JavaLink[] I get: LinkObject['/Applications/Mathematica.app/SystemFiles/Links/JLink/JLink.app/Con‌​tents/MacOS/JavaApplicationStub' -init "/tmp/m000001265201",81,4] – Murta Dec 30 '13 at 2:10
Hm, on OSX, everything is different. I guess you have 256MB too. You could check the file FileNames["InstallJava.m", {\$InstallationDirectory}, Infinity] and search for -Xmx. – halirutan Dec 30 '13 at 2:50

You need to use JVMArguments

<<JLink;
InstallJava[];
ReinstallJava[JVMArguments -> "-Xmx512m"]


Shameless copy From Wolfram ;-)

Or directly...

InstallJava[JVMArguments -> "-Xmx512m"]


The options available depend on your JVM runtime. The standard way to get the non-standard options is (in the shell) java -X

-
For Mac use: ReinstallJava[CommandLine->"java",JVMArguments->"-Xmx512m"];` – Murta Apr 30 '14 at 15:38
Nice link here – Murta Apr 30 '14 at 15:46