I cannot save the input into my database. Can anybody help me?
There's SSL problem but it is able to solve by setting SSL to false, but the data seems like only able to read but not save into my database.
package first;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.Connection;
import javax.swing.JOptionPane;
public class CustomersForm extends javax.swing.JFrame {
public CustomersForm() {
initComponents();
}
private void jButton_addcusActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
try {
Class.forName("com.mysql.jdbc.Driver");
String connectionURL = "jdbc:mysql://localhost:3308/java_his_db";
Connection con = DriverManager.getConnection(connectionURL, "root", "");
String sql = "Insert into customers ('fname') values (?)";
PreparedStatement ps = con.prepareStatement(sql);
ps.setString(2, jTextField_fname.getText());
ps.executeUpdate();
System.out.println("YES");
con.close();
}
catch(Exception e){
JOptionPane.showMessageDialog(rootPane, "Blank or Wrong User Profile", "Insert Error", 2);
}
}
private void jTextField_fnameActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…