Here's my code for a button that add values into an empty database.
The program skips system.out.println("1");
And the database is still empty. I can't figure out why
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
String url = "jdbc:mysql://localhost:3306/xxxxxxxxxxxx";
String driver = "com.mysql.jdbc.Driver";
String user = "xxxxxxxxxxxx";
String pass = "xxxxxxxxx";
try
{
Class.forName(driver).newInstance();
Connection con = (Connection)DriverManager.getConnection(url,user,p ass);
System.out.println("Connected");
Statement st=(Statement) con.createStatement();
ResultSet rs1=(ResultSet) st.executeQuery("select count from path");
if(rs1.next()){if(rs1.getInt(1)==0){a=0;}
if(rs1.getInt(1)==1){a=1;}
else{a=rs1.getInt(1);}
st.executeUpdate("insert into path(idPath,HarborDestination,HarborDeparture,Pric e,Type,FinalPrice) values('"+a+"','"+jTextField2.getText()+"','"+jTex tField3.getText()+"','"+jTextField4.getText()+"',' "+jTextField5.getText()+"','"+jTextField6.getText( )+"')");
System.out.println("1");
}
}
catch(Exception e){
System.out.println("Not Connected");
}}