Estou com um erro que não consigo tirar

3 respostas
java
E
private void SaidaRmov() throws SQLException {

try {

rdbsaida.isSelected();

// rotina para saida do estoque	

// criar variáveis de movimentacao

int v1 = Integer.parseInt(txtquantidademov.getText());

int v2 = Integer.parseInt(txtqtdestoque.getText());

int v3 = (v2 - v1);

if (v1 > v2) {

JOptionPane.showMessageDialog(null, ESTOQUE INSUFICIENTE !!!);
} else {
	if (v2 - v1 == v3) {
	    int confirma = JOptionPane.showConfirmDialog(null, "DESEJA SALVAR ESTE MOVIMENTO,?", "ATENÇÃO", JOptionPane.YES_NO_OPTION);
	    if (confirma == JOptionPane.YES_OPTION) {
		String sql = "update estoque set quantidade=? where idSTQ=?";

		pst = conexao.prepareStatement(sql);
		pst.setInt(1, v3);
		pst.setString(2, txtidmov.getText().trim());

		txtupestoque.setText(String.valueOf(v3));
		String ID = txtidmov.getText().trim();
		String TIPO = lbltipo.getText().trim();
		String PRODUTO = txtprodutomov.getText().trim();
		String IDUSER = txtidstq.getText().trim();
		String SETOR = cbsetormov.getSelectedItem().toString();
		String USUARIO = txtusuariomov.getText().trim();
		String QUANTIDADE = txtupestoque.getText().trim();
		String CA = txtcamov.getText().trim();
		String DATA = txtdatamov.getText().trim();
		String OS = txtosmov.getText().trim();

		//PASSANDO OS CAMPOS PARA TABELA 
		DefaultTableModel val = (DefaultTableModel) tblmov.getModel();
		val.addRow(new String[]{ID, TIPO, PRODUTO, IDUSER, SETOR, USUARIO, QUANTIDADE, CA, DATA, OS});

		pst.executeUpdate();
		// limpando campos e as tebelas de pesquisa 
		txtidmov.setText(null);
		txtprodutomov.setText(null);
		txtidstq.setText(null);
		txtusuariomov.setText(null);
		txtquantidademov.setText(null);
		txtcamov.setText(null);
		while (tblmovpesq.getModel().getRowCount() > 0) {
		    ((DefaultTableModel) tblmovpesq.getModel()).removeRow(0);
		}
		while (tblpesquisaUSER.getModel().getRowCount() > 0) {
		    ((DefaultTableModel) tblpesquisaUSER.getModel()).removeRow(0);
		}
	    }
	}
    }

o erro ta sendo esse!!!
( java.lang.NumberFormatException: For input string: “” )

3 Respostas

F
  1. Formate o seu código corretamente. Selecione TUDO que é código e clique no botão de pré-formatação (</>), nas suas ferramentas de postagem;
  2. Nos forneça mais detalhes. Postar o stacktrace (o erro completo que aparece no seu console) já é um bom começo;
  3. Dá uma lida nesse tópico para entender a importância dos dois itens acima.
G

Analisando seu código e o erro o que está acontecendo, é que em uma dessas linhas ou nas duas linhas
int v1 = Integer.parseInt(txtquantidademov.getText());
int v2 = Integer.parseInt(txtqtdestoque.getText());
está tentando converter uma string vazia para inteiro;

E

Obrigado vou dar uma olhada aqui vlw

Criado 12 de junho de 2019
Ultima resposta 12 de jun. de 2019
Respostas 3
Participantes 3