Preenchimento do Banco de Dados
Autor: Bárbara Aniele | Publicado: 2012-08-03T06:21:00-07:00

&nbsp;Foi definido sequencialmente a quantidade de cada tabela e após isso executado o programa abaixo, gerando o tamanho esperado de 5GB no Banco de Dados.

____________________________________________________________________________ 

/*
&nbsp;* Created on 17/06/2012
&nbsp;* 
&nbsp;* TODO To change the template for this generated file go to
&nbsp;* Window - Preferences - Java - Code Style - Code Templates
&nbsp;*/
//import java.util.ArrayList;

public class tebd_insert {

&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; public static void main(String args[]) throws Exception{
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //ArrayList&lt;Integer&gt; medicos = new ArrayList&lt;Integer&gt;(); // 4
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //ArrayList&lt;Integer&gt; pacotes = new ArrayList&lt;Integer&gt;(); // 5
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Boolean slashes = true;&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; String cidade;
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; String estado;
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; int x = 0;
&nbsp;&nbsp;&nbsp; MyTableCollection tabelas = new MyTableCollection();

&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Integer c_qtd_medico = 60;
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Integer c_qtd_empresa = c_qtd_medico * 50;
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Integer c_qtd_exames = 5;
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Integer c_qtd_funcionario_empresa = c_qtd_empresa * 30;
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Integer c_qtd_func_empr_exames = 20 * c_qtd_funcionario_empresa * c_qtd_exames;
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Integer c_qtd_laudo = c_qtd_func_empr_exames;

&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Integer qtd_medico = c_qtd_medico;
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Integer qtd_empresa = qtd_medico * 5;
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //Integer qtd_exames = 5;
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Integer qtd_funcionario_empresa = 400;
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Integer qtd_func_empr_exames = 200;
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Integer qtd_laudo = 200;

&nbsp;&nbsp;&nbsp; MyTable empresa = new MyTable("clin_empresa", c_qtd_empresa); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; empresa.addColumn("empr_codigo", new MyPKColumn() ); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; empresa.addColumn("empr_cnpj", new MyColumn("numeric", 15) ); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; empresa.addColumn("empr_razao_social", new MyColumn("% % %",6,12) ); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; empresa.addColumn("empr_fantasia", new MyColumn("% %",6,12) ); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; empresa.addColumn("empr_rua", new MyColumn("% %",6,12) ); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; empresa.addColumn("empr_numero", new MyColumn("numeric", 5) ); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; empresa.addColumn("empr_complemento", new MyColumn("% %",6,12) ); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; empresa.addColumn("empr_bairro", new MyColumn("%",6,12) ); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; empresa.addColumn("empr_cidade", new MyColumn("% %",6,19) ); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; empresa.addColumn("empr_estado", new MyColumn("% % %",6,12) ); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; empresa.addColumn("empr_pais", new MyColumn("varchar", 105) ); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; empresa.addColumn("empr_data_cadastro", new MyColumn("date", null) ); //timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; empresa.addColumn("empr_ativo", new MyColumn("int", null ) );
&nbsp;&nbsp;&nbsp; tabelas.add(empresa);

&nbsp;&nbsp;&nbsp; MyTable exames = new MyTable("clin_exames", c_qtd_exames); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; exames.addColumn("exam_codigo", new MyPKColumn() ); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; exames.addColumn("exam_nome", new MyColumn("varchar", 65) ); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; exames.addColumn("exam_ativo", new MyColumn("int", null) );
&nbsp;&nbsp;&nbsp; tabelas.add(exames);

&nbsp;&nbsp;&nbsp; MyTable func_empr_exames = new MyTable("clin_func_empr_exames", c_qtd_func_empr_exames); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; func_empr_exames.addColumn("clin_func_empr_exam_codigo", new MyPKColumn() ); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; func_empr_exames.addColumn("clin_func_empr_exam_fk_exames", new MyFKColumn("clin_exames", "exam_codigo") ); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; func_empr_exames.addColumn("clin_func_empr_exam_fk_funcionario", new MyFKColumn("clin_funcionario_empresa", "func_empr_codigo") ); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; func_empr_exames.addColumn("clin_func_empr_exam_fk_funcionario", new MyColumn("int", null) ); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; func_empr_exames.addColumn("clin_func_empr_exam_fk_exames", new MyColumn("int", null) ); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; func_empr_exames.addColumn("clin_func_empr_exam_data_exame", new MyColumn("date", null) ); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; func_empr_exames.addColumn("clin_func_empr_exam_qtd", new MyColumn("??") ); // reduzindo até 99 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; func_empr_exames.addColumn("clin_func_empr_exam_valor", new MyColumn("??.??") ); //decimal 10,2
&nbsp;&nbsp;&nbsp; tabelas.add(func_empr_exames);

&nbsp;&nbsp;&nbsp; MyTable funcionario_empresa = new MyTable("clin_funcionario_empresa", c_qtd_funcionario_empresa); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; funcionario_empresa.addColumn("func_empr_codigo", new MyPKColumn() ); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; funcionario_empresa.addColumn("func_empr_fk_empresa", new MyFKColumn("clin_empresa", "empr_codigo") ); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; funcionario_empresa.addColumn("func_empr_fk_empresa", new MyColumn("int", null) ); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; funcionario_empresa.addColumn("func_empr_nome", new MyColumn("% %",6,12) ); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; funcionario_empresa.addColumn("func_empr_rg", new MyColumn("????????-??") );
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; funcionario_empresa.addColumn("func_empr_cpf", new MyColumn("???.???.???-??") ); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; funcionario_empresa.addColumn("func_empr_rua", new MyColumn("% %",6,12) ); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; funcionario_empresa.addColumn("func_empr_numero", new MyColumn("numeric", 5) ); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; funcionario_empresa.addColumn("func_empr_complemento", new MyColumn("% %",6,20) ); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; funcionario_empresa.addColumn("func_empr_bairro", new MyColumn("%",6,12) ); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; funcionario_empresa.addColumn("func_empr_cidade", new MyColumn("% %",6,12) ); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; funcionario_empresa.addColumn("func_empr_estado", new MyColumn("varchar", 145) ); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; funcionario_empresa.addColumn("func_empr_pais", new MyColumn("varchar", 105) ); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //funcionario_empresa.addColumn("func_empr_data_cadastro", new MyColumn("date", null) ); //timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; funcionario_empresa.addColumn("func_empr_ativo", new MyColumn("int", null) );
&nbsp;&nbsp;&nbsp; tabelas.add(funcionario_empresa);

&nbsp;&nbsp;&nbsp; MyTable laudo = new MyTable("clin_laudo", c_qtd_laudo); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; laudo.addColumn("laudo_fk_func_empr_exames", new MyPKColumn() ); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; laudo.addColumn("laudo_fk_medico", new MyPKColumn() ); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; laudo.addColumn("laudo_fk_func_empr_exames", new MyFKColumn("clin_func_empr_exames", "clin_func_empr_exam_codigo") ); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; laudo.addColumn("laudo_fk_medico", new MyFKColumn("clin_medico", "medi_codigo") ); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; laudo.addColumn("laudo_data", new MyColumn("date", null) ); //
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; laudo.addColumn("laudo_descricao", new MyColumn("text", 510) );
&nbsp;&nbsp;&nbsp; tabelas.add(laudo);

&nbsp;&nbsp;&nbsp; MyTable medico = new MyTable("clin_medico", c_qtd_medico); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; medico.addColumn("medi_codigo", new MyPKColumn() ); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; medico.addColumn("medi_nome", new MyColumn("% %",6,12) ); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; medico.addColumn("medi_crm", new MyColumn("numeric", 15) ); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; medico.addColumn("medi_especialidade", new MyColumn("varchar", 10) ); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; medico.addColumn("medi_ativo", new MyColumn("varchar", 45) );
&nbsp;&nbsp;&nbsp; tabelas.add(medico);
&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; Double objetivo = 5368709120.0;
&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; System.out.println("Size in Bytes");
&nbsp;&nbsp;&nbsp; System.out.println(tabelas.calculate());
&nbsp;&nbsp;&nbsp; System.out.println(objetivo);
&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; System.out.println("objetivo alcancado = " + (tabelas.calculate() &gt;= objetivo) );
&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; MyDataAccess.open();
&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; //Inserindo 5 exames 
&nbsp;&nbsp;&nbsp; exames.setCustomValue(slashes, "exam_nome",&nbsp; "Admissional");
&nbsp;&nbsp;&nbsp; exames.setCustomValue(slashes, "exam_ativo", "1");
&nbsp;&nbsp;&nbsp; MyDataAccess.ExecuteInsert(exames.generateInsert());
&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; exames.setCustomValue(slashes, "exam_nome",&nbsp; "Retorno ao Trabalho");
&nbsp;&nbsp;&nbsp; exames.setCustomValue(slashes, "exam_ativo", "1");
&nbsp;&nbsp;&nbsp; MyDataAccess.ExecuteInsert(exames.generateInsert());
&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; exames.setCustomValue(slashes, "exam_nome",&nbsp; "Mudanca de Funcao");
&nbsp;&nbsp;&nbsp; exames.setCustomValue(slashes, "exam_ativo", "1");
&nbsp;&nbsp;&nbsp; MyDataAccess.ExecuteInsert(exames.generateInsert());
&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; exames.setCustomValue(true, "exam_nome",&nbsp; "Periódico");
&nbsp;&nbsp;&nbsp; exames.setCustomValue(slashes, "exam_ativo", "1");
&nbsp;&nbsp;&nbsp; MyDataAccess.ExecuteInsert(exames.generateInsert());
&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; exames.setCustomValue(true, "exam_nome",&nbsp; "Demissional");
&nbsp;&nbsp;&nbsp; exames.setCustomValue(slashes, "exam_ativo", "1");
&nbsp;&nbsp;&nbsp; MyDataAccess.ExecuteInsert(exames.generateInsert());
&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; // Inserindo valores
&nbsp;&nbsp;&nbsp; Integer empresa_id;
&nbsp;&nbsp;&nbsp; Integer func_empr_exames_id;
&nbsp;&nbsp;&nbsp; Integer funcionario_id;
&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; for(Integer i = 0; i &lt; qtd_medico; i++){
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //medico.setCustomValue(slashes, "medi_nome", XXXXXXXX ); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //medico.setCustomValue(slashes, "medi_crm", XXXXXXXX ); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //medico.setCustomValue(slashes, "medi_especialidade", XXXXXXXX ); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; medico.setCustomValue(slashes, "medi_ativo", "1");
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; MyDataAccess.ExecuteInsert(medico.generateInsert());
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //System.out.print("M"+i);
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; System.out.println("");
&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; for(Integer i = 0; i &lt; qtd_empresa; i++){
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; x++;
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (x % 2 == 0){
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; x=0;
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; MyDataAccess.close();
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; MyDataAccess.open();
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //System.out.print("E"+i);
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; cidade = MyRand.RandomNome(10, 15);
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //cep = MyRand.MaskedNumber("??????-???");
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; estado = MyRand.RandomUF();
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //csdsda
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //empresa.setCustomValue(slashes, "empr_cnpj", XXXXXXXX ); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //empresa.setCustomValue(slashes, "empr_razao_social", XXXXXXXX ); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //empresa.setCustomValue(slashes, "empr_fantasia", XXXXXXXX ); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //empresa.setCustomValue(slashes, "empr_rua", XXXXXXXX ); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //empresa.setCustomValue(slashes, "empr_numero", XXXXXXXX ); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //empresa.setCustomValue(slashes, "empr_complemento", XXXXXXXX ); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //empresa.setCustomValue(slashes, "empr_bairro", XXXXXXXX ); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //empresa.setCustomValue(slashes, "empr_cidade", cidade); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; empresa.setCustomValue(slashes, "empr_estado", MyRand.RandomUF()); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; empresa.setCustomValue(slashes, "empr_pais", "Brasil" ); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //empresa.setCustomValue(slashes, "empr_data_cadastro", XXXXXXXX ); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; empresa.setCustomValue(slashes, "empr_ativo", "1" );

&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; empresa_id = MyDataAccess.ExecuteInsert(empresa.generateInsert());
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; for(Integer j = 0; j &lt; qtd_funcionario_empresa; j++){
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //System.out.print("F"+j);
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; funcionario_empresa.setCustomValue(slashes, "func_empr_fk_empresa", empresa_id.toString() ); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //funcionario_empresa.setCustomValue(slashes, "func_empr_nome", "XXXXXXXX" ); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; funcionario_empresa.setCustomValue(slashes, "func_empr_rg", MyRand.MaskedNumber("????????-??") ); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; funcionario_empresa.setCustomValue(slashes, "func_empr_cpf", MyRand.MaskedNumber("???.???.???-??") ); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //funcionario_empresa.setCustomValue(slashes, "func_empr_rua", "XXXXXXXX" ); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //funcionario_empresa.setCustomValue(slashes, "func_empr_numero", "XXXXXXXX" ); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //funcionario_empresa.setCustomValue(slashes, "func_empr_complemento", "XXXXXXXX" ); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //funcionario_empresa.setCustomValue(slashes, "func_empr_bairro", "XXXXXXXX" ); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //funcionario_empresa.setCustomValue(slashes, "func_empr_cidade", "XXXXXXXX" ); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; funcionario_empresa.setCustomValue(slashes, "func_empr_estado", MyRand.RandomUF()); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; funcionario_empresa.setCustomValue(slashes, "func_empr_pais", "Brasil"); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //funcionario_empresa.setCustomValue(slashes, "func_empr_data_cadastro", "XXXXXXXXXX"); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; funcionario_empresa.setCustomValue(slashes, "func_empr_ativo", "1");

&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; funcionario_id = MyDataAccess.ExecuteInsert(funcionario_empresa.generateInsert());
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Boolean demitido = false;
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //funcionarios fazendo exames.
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; for(Integer k = 0; k &lt; qtd_func_empr_exames; k++){

&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //System.out.print("x"+k);
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; /*
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;* Liga um funcinario a um exame ?
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;* 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;* */
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //ids dos exames de 2 a 5
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Integer exame_id;
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if(k == 0){
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; exame_id = 0;
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; else if( (!demitido) &amp;&amp; (k == 4) &amp;&amp; (MyRand.RandomInt(0,50) == 35) )
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; exame_id = 4;
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; else{
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; exame_id = MyRand.RandomInt(1,3);
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //um exame realizado
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; func_empr_exames.setCustomValue(slashes, "clin_func_empr_exam_fk_funcionario", funcionario_id.toString() ); 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; func_empr_exames.setCustomValue(false, "clin_func_empr_exam_fk_exames", "(SELECT c.`exam_codigo` FROM clin_exames c LIMIT "+exame_id+",1)" );
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //func_empr_exames.setCustomValue(slashes, "clin_func_empr_exam_data_exame", XXXXXXXX );
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //func_empr_exames.setCustomValue(slashes, "clin_func_empr_exam_qtd", XXXXXXXX );
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //func_empr_exames.setCustomValue(slashes, "clin_func_empr_exam_valor", XXXXXXXX );
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; func_empr_exames_id = MyDataAccess.ExecuteInsert(func_empr_exames.generateInsert());
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //um laudo
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; laudo.setCustomValue(slashes, "laudo_fk_func_empr_exames", func_empr_exames_id.toString());
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; laudo.setCustomValue(false, "laudo_fk_medico", "(SELECT c.`medi_codigo` FROM clin_medico c LIMIT "+MyRand.RandomInt(0,qtd_medico-1)+",1)"); //Select???
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; MyDataAccess.ExecuteInsert(laudo.generateInsert());
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //System.out.println("");
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //System.out.println("");
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; MyDataAccess.close();
&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
/*
clin_medico
clin_empresa
&nbsp;&nbsp;&nbsp; clin_exames
&nbsp;&nbsp;&nbsp; clin_funcionario_empresa
&nbsp;&nbsp;&nbsp; clin_func_empr_exames -- clin_laudo
*/
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; }
&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; 
}