package BD;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class InsereProduto {

	public static void InsereProdutos() throws SQLException {
		try {
			String[] aux1 = new String[50];
			int[] aux2 = new int[50];
			int[] aux3 = new int[50];
			aux1[0] = "Arroz";
			aux1[1] = "Banana";
			aux1[2] = "Farinha";
			aux1[3] = "Iogurte";
			aux1[4] = "Maca";
			aux1[5] = "Pizza";
			aux1[6] = "Abacate";
			
			aux2[0] = 3;
			aux2[1] = 1;
			aux2[2] = 6;
			aux2[3] = 2;
			aux2[4] = 1;
			aux2[5] = 5;
			aux2[6] = 2;
			
			aux3[0] = 255;
			aux3[1] = 255;
			aux3[2] = 255;
			aux3[3] = 255;
			aux3[4] = 255;
			aux3[5] = 255;
			aux3[6] = 255;
			
			
			Connection con2 = ConnectionFactory.getConnection();

			for (int i = 0; i < 7; i++) {
				PreparedStatement stmt2 = con2
						.prepareStatement("insert into "
								+ "produtos(nome,valor,disponivel) values "
								+ "(?,?,?)");
				stmt2.setString(1, aux1[i]);
				stmt2.setInt(2, aux2[i]);
				stmt2.setInt(3, aux3[i]);
				stmt2.execute();
				stmt2.close();
			}
			con2.close();			
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}
}
