Struts

3 respostas
mictexx

Bom dia,

eu estou usando MySql e driver “mysql-connector-java-3.0.14-production-bin.jar”

quando executo esse metodo:

========================================
public void deleteUser(int idUsuario) throws SQLException {
Connection conn = null;
PreparedStatement stmt = null;
ResultSet rs = null;
try {
conn = getConnection();
stmt = conn.prepareStatement(
“delete from usuario where id_usuario = ?”);
stmt.executeUpdate();
}
catch (SQLException e) {
throw e;
}
finally {
if (rs != null) {
rs.close();
}
if (stmt != null) {
stmt.close();
}
}
}

Obtenho esse erro:

java.sql.SQLException: No value specified for parameter 1

alguém tem alguma dica?

3 Respostas

mictexx

Valew java_coffe,

obrigado brow!

I
public void extinguir(String id_usuario) throws SQLException {
	
		PreparedStatement prepStatement = null;

		String sql = " delete from usuario where id_usuario = ? ";

		
		try 
		{
			conexao = ControladorConexao.abrirConexao();

			prepStatement = conexao.prepareStatement(sql);
			prepStatement.setString(1, id_usuario);
			prepStatement.executeUpdate();			
			
			System.out.println("            Extinguido com Sucesso !                 \n");
		
		} catch (SQLException e)  {
		
			throw new SQLException(e.getMessage());
		
		} finally {
			prepStatement.close();
			conexao.close();
		}
	
	}
}

Tenta desta forma aí e vc se da certo rapa !

I
Faltou vc fazer isso por isso nao deu certo no seu exmplo !

Faltou vc fazer isso por isso nao deu certo no seu exmplo !

Criado 29 de agosto de 2006
Ultima resposta 29 de ago. de 2006
Respostas 3
Participantes 2