Code example for Connection

Methods: prepareStatement

0
	 
	public void adiciona(Ponto ponto){
		String sql = "INSERT INTO ponto (idsensor, idcomponente, tagponto, posicao, tipomedicao, descricao, al, sd) VALUES (?,?,?,?,?,?,?,?)";
		 
		try{ 
			PreparedStatement stmt = connection.prepareStatement(sql);
			 
			stmt.setInt(1, ponto.getIdSensor());
			stmt.setInt(2, ponto.getIdComponente());
			stmt.setString(3, ponto.getTagPonto());
			stmt.setString(4, ponto.getPosicao());
			stmt.setString(5, ponto.getTipoMedicao());
			stmt.setString(6, ponto.getDescricao());
			stmt.setInt(7, ponto.getAl());
			stmt.setInt(8, ponto.getSd());
			 
			stmt.execute();
			stmt.close();
		} catch (SQLException e){
			throw new RuntimeException(e);