给定以下代码,我如何使用myInt
in private void jButton1
from private void jButton2
?
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
int myInt = (Integer)jSpinner1.getValue();
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
int b = 0;
int c = myInt;
do {
try {
Object newInstance = Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://localhost/rk","root","root");
PreparedStatement ps = (PreparedStatement) con.prepareStatement("INSERT INTO factors VALUES(?,?,?,?,?,?)");
ps.setString(1,jTextField7.getText());
ps.setString(2,jTextField8.getText());
ps.setString(3,jTextField9.getText());
ps.setString(4,jTextField10.getText());
ps.setString(5,jTextField11.getText());
ps.setString(6,jTextField12.getText());
ps.executeUpdate();
jTextField7.setText("");
jTextField8.setText("");
jTextField9.setText("");
jTextField10.setText("");
jTextField11.setText("");
jTextField12.setText("");
}
catch (Exception e) {
System.out.println(e);
}
b++;
} while(b < my);
}