Pessoal, como eu resolvo esse problema “java.lang.OutOfMemoryError: Java heap space”, estou usando o Netbeans já configurei ele par -Xmx1024m nas configurações do netBeans mas continua a mesma coisa. Estou tentanto le um arquivo em xml de 200Mb, que contem uma serie de dados para importar para um bd.
Usei o Kettle para realizar essa mesma função mas continua a mesma coisa dando o mesmo erro. Como eu poço solucionar esse pequeno problema?
public class T {
private Document doc = null;
private String enderco;
static long aux = 0;
public void executarPopulation(){
try{
setEnderco("C:\\BASE.XML");
setDoc();
Element base_venda = getDoc().getRootElement();
List<Element> lista = base_venda.getChildren();
VendasDAO v = new VendasDAO();
for(Element el: lista){
v.PreencherSalvar(el);
System.out.println(++aux);
}
}catch(IOException e){
e.printStackTrace();
System.out.println("Arquivo não encontrado");
}catch(JDOMException e){
System.out.println("Problema no JDO");
}catch(SQLException e){
System.out.println("Problema no SQL");
}
}
public void setDoc() throws JDOMException, IOException {
SAXBuilder builder = new SAXBuilder();
this.doc = (Document) builder.build(getEnderco());
}
public class VendasDAO extends GenericDAO<Vendas> {
Vendas v = new Vendas();
//Remove todo o conteudo;
public void PreencherSalvar(Element e) throws SQLException {
v.setCod(Integer.parseInt(e.getChildText("cd")));
v.setCod_setor(Integer.parseInt(e.getChildText("cd_setor")));
v.setCod_emp(Integer.parseInt(e.getChildText("cd_emp")));
v.setCod_origem(Integer.parseInt(e.getChildText("cd_or")));
v.setCategoria(e.getChildText("cd_categoria"));
v.setCod_prod(Long.parseLong(e.getChildText("cd_produto")));
v.setCod_ger(Integer.parseInt(e.getChildText("cd_ger")));
v.setCod_ger_setor(Integer.parseInt(e.getChildText("cd_ger_setor")));
v.setCod_superv(Integer.parseInt(e.getChildText("cd_supervl")));
v.setCod_vendedor(Integer.parseInt(e.getChildText("cd_vendedor")));
v.setTipo_pessoa(e.getChildText("tp_pessoa"));
v.setCpf(Integer.parseInt(e.getChildText("cpf")));
v.setCnpj(Integer.getInteger(e.getChildText("cnpj")));
v.setCor(Integer.parseInt(e.getChildText("cor")));
v.setCod_tipo(e.getChildText("cd_tipo"));
v.setSegmento(Integer.parseInt(e.getChildText("segmento")));
v.seTt_fis(Integer.parseInt(e.getChildText("tt_fis")));
v.setTt_vol(Integer.parseInt(e.getChildText("tt_vol")));
v.setValor(Float.parseFloat(e.getChildText("valor")));
v.setQtd_fis(Integer.parseInt(e.getChildText("qtd_fis")));
v.setQtd_vol(Integer.parseInt(e.getChildText("qtd_vol")));
v.setVl_real(Float.parseFloat(e.getChildText("vl_real")));
v.setDevolv_fis(Integer.parseInt(e.getChildText("Devolv_fis")));
v.setDevolv_vol(Integer.parseInt(e.getChildText("Devolv_vol")));
v.setVl_devolv(Float.parseFloat(e.getChildText("vl_devolv")));
salvar(v);
}
@Override
public void salvar(Vendas v) throws SQLException {
String query = "INSERT INTO v_dia( cod, cod_setor, cod_emp,"
+ "cod_or, categoria, cod_prod, cod_ger, cod_ger_setor,"
+ "cod_superv, cod_vendedor, tipo_pessoa, cpf, cnpj,"
+ " cor, cod_tipo, cod_segmento, tt_fis, tt_vol,"
+ "valor, qtd_fis, qtd_vol, vl_real, qtd_devolv_fis,"
+ " qtd_devolv_vol, vl_devolv)"
+ "VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
executeCommand(query,
v.getCod(),v.getCod_setor(),v.getCod_emp(),v.getCod_or(),
v.getCategoria(),v.getCod_prod(),v.getCod_ger(), v.getCod_ger_setor(),
v.getCod_superv(), v.getCod_vendedor(), v.getTipo_pessoa(),
v.getCpf(),v.getCnpj(),v.getCor(),
v.getCod_tipo(),v.getCod_segmento(), v.getTt_fis(),
v.getTt_vol(), v.getValor(), v.getQtd_fis(),v.getQtdl_vol(),
v.getVl_real(), v.getQtd_devolv_fis(),v.getQtd_devolv_vol(),
v.getVl_devolv());
}
}
public abstract class GenericDAO<T> {
public PreparedStatement getStatement(String sql) throws SQLException{
return ConexaoBD.getConnection().prepareStatement(sql);
}
public void executeCommand(String query, Object...params) throws SQLException{
PreparedStatement ps = getStatement(query);
for(int i = 0; i < params.length; i++){
ps.setObject(i+1, params[i]);
}
ps.executeUpdate();
ps.close();
}
public abstract void salvar(T t)throws SQLException;
public abstract boolean limpar();
public abstract void PreencherSalvar(Element e)throws SQLException;
}