我正在开发一个简单的应用程序,可用于创建啤酒配方。该应用程序采用存储在数据库中的特定值,并使用数学公式和数量(用户输入)来计算啤酒规格。
当我运行这段代码(即“计算”按钮下的代码)时,我收到很多异常,其中主要是 java.awt 异常、javax.swing 异常和一些 SQL 异常。列出的变量是正确的,并且变量的拼写没有输入错误。
private void Calculate_BrewActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
nameBrew = jTextField1.getText();
Connection connFerm = null;
Connection connHops = null;
try {
vols = Float.parseFloat(jTextField2.getText());
}
catch (NumberFormatException e) {
JOptionPane.showMessageDialog(null, "Enter a valid number...");
}
fermone = (String) jComboBox1.getSelectedItem();
try {
fermmass1 = Float.parseFloat(jTextField6.getText());
}
catch (NumberFormatException e) {
JOptionPane.showMessageDialog(null, "Enter a valid number...");
}
hop1 = (String) jComboBox9.getSelectedItem();
try {
hopmass1 = Float.parseFloat(jTextField10.getText());
}
catch (NumberFormatException e) {
JOptionPane.showMessageDialog(null, "Enter a valid number...");
}
//...............................................................................
try {
connFerm = DriverManager.getConnection("jdbc:mysql://localhost:3306/fermentable_info", "root", "nerdswonka");
} catch (SQLException ex) {
Logger.getLogger(Create_Page.class.getName()).log(Level.SEVERE, null, ex);
}
try {
connHops = DriverManager.getConnection("jdbc:mysql://localhost:3306/hops_info", "root", "nerdswonka");
} catch (SQLException ex) {
Logger.getLogger(Create_Page.class.getName()).log(Level.SEVERE, null, ex);
}
海绵宝宝撒
相关分类