Quantcast
Channel: Programação - GUJ
Viewing all articles
Browse latest Browse all 33093

Como pegar o valor de um select para adicionar no banco de dados?

$
0
0

@Michael.Jordan escreveu:

<div class="form-group">
				<label for="txtGenro">Gênero</label>
				<select name="genero.id">
					<option value=""></option>
					<option value="Acao">Ação</option>
					<option value="Aventura">Aventura</option>
					<option value="Terror">Terror</option>
				</select>
			</div>

public List<Filme> buscarTodos() {
		List<Filme> filmes = new ArrayList<Filme>();
		final String SQL_LISTAR = "SELECT id,nome FROM genero";
		
		try {
			fabricaConexoes.abrir();
			
			//Criando o statment
			PreparedStatement stmt = fabricaConexoes.getConexao().prepareStatement(SQL_LISTAR);
			
			//Executando a busca
			ResultSet resultado = stmt.executeQuery();
			
			while(resultado.next()){
				Filme filme = new Filme();
				filme.setId(resultado.getLong("id"));
				filme.setNome(resultado.getString("nome"));

                          // AQUI QUERO PEGAR O VALOR DO SELECT SELECIONADO PARA ADICIONAR NO BANCO
				
				//Adicionando o filme na lista
				filmes.add(filme);
				
			}
			
			//Fechando o ResultSet
			resultado.close();
			
		} catch (Exception e) {
			e.printStackTrace(); // Exibe mensagem de erro
			throw new RuntimeException();
		}finally {
			fabricaConexoes.fechar();
		}
		
		return filmes;
	}

Mensagens: 1

Participantes: 1

Ler tópico completo


Viewing all articles
Browse latest Browse all 33093


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>