[Java][MySQL] ¡Help! Insert

Status
Not open for further replies.

Nasty

New Member
Feb 26, 2012
23
2
Well this is my database:
basededatos.png

And this Java code:

  1. btnAlta = new ("Alta");
  2. btnAlta.addActionListener(new () {
  3. public void actionPerformed( arg0) {
  4. labelResultado.setText("");
  5. try {
  6. conexion= .getConnection("jdbc:mysql://localhost/bd1","root" ,"");
  7. comando=conexion.createStatement();
  8. comando.executeUpdate("insert into articulos(descripcion,precio) values ('"+tf1.getText()+"',"+tf2.getText()+")");
  9. conexion.close();
  10. labelResultado.setText("se registraron los datos");
  11. tf1.setText("");
  12. tf2.setText("");
  13. } catch( ex){
  14. setTitle(ex.toString());
  15. } }
  16. });
Now I want to do is:
Each time you give to "High" in the table field "code" generated a number: 1
When will the second time, it detects that there is a 1 and place a 2. Bone in order,
in each "insert" generated a number more ...
 

Adil

DevBest CEO
May 28, 2011
1,276
714
Code:
comando.executeUpdate("INSERT into articulos(descripcion,precio) values ('"+tf1.getText().toString()+"',"+tf2.getText().toString()+")");
Try that
 
Status
Not open for further replies.

Users who are viewing this thread

Top