Ai galera fiz o código abaixo, só que ao executar o update ele da erro, eu peguei o código que sai do strSQL e joguei no sql e deu certo, não sei pq nao está dando, alguem ajuda.
[code]import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class geraserial extends JanelaConf implements ActionListener{
Connection Con;
static Statement Stm;
String strMsg = “”;
int i2, i3, serial2, serial4, serial6, serial8,serial10,serial12,serial14,serial16;
double serial, serial3, serial5, serial7, serial9, serial11, serial13,serial15;
JTextField qtdcarro, serialg, sger;
JLabel qtdc, seriall;
String i;
JButton gser;
public geraserial(){
super(“Serial”, new Dimension (280, 180));
serial();
}
public void serial(){
qtdc = new JLabel("Quantidade de Carros:");
add(qtdc);
qtdc.setBounds(10,10,150,25);
qtdcarro = new JTextField();
add(qtdcarro);
qtdcarro.setBounds(150,10,50,25);
gser = new JButton("Gerar");
add(gser);
gser.setBounds(10,100,100,25);
gser.addActionListener(this);
sger = new JTextField();
add(sger);
sger.setBounds(0,0,0,0);
serial = Math.random()*11;
serial2 = (int) Math.round(serial);
serial3 = Math.random()*22;
serial4 = (int) Math.round(serial3);
serial5 = Math.random()*33;
serial6 = (int) Math.round(serial5);
serial7 = Math.random()*44;
serial8 = (int) Math.round(serial7);
serial9 = Math.random()*55;
serial10 = (int) Math.round(serial9);
serial11 = Math.random()*66;
serial12 = (int) Math.round(serial11);
serial13 = Math.random()*77;
serial14 = (int) Math.round(serial13);
serial15 = Math.random()*88;
serial16 = (int) Math.round(serial15);
sger.setText(serial2+"-"+serial4+"-"+serial6+"-"+serial8+"-"+serial10+"-"+serial12+"-"+serial14+"-"+serial16);
}
public void actionPerformed(ActionEvent e){
if(e.getSource() == gser){
cserial();
}
}
public void cserial(){
String strSQL = "";
strSQL = "INSERT INTO serial (serial,qtdcarros) VALUES ('"+sger.getText().trim()+"','"+qtdcarro.getText().trim()+"')";
try{
Stm.executeUpdate(strSQL);
}
catch(SQLException sqle){}
}
public static void main(String[] args){
new geraserial().show();
}
}
[/code]