I want to run my .jar file in another computer that does not have MYSQL or netbeans installed. In my computer it is working fine. I am using wamp MYSQL database. I have tried it on another machine and it says:
com.mysql.jbbc.exceptions.jdbc4.communicationsException: communication link failure
.I am trying this to see if it would work for other people who do not have IDE or WAMP installed if I gave them my app.
Here is my sample code:
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
try{
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/"
+ "employee_certificate","admin","jkvf");
String sql="select * from credentials where username=? and password=?";
stmt= con.prepareStatement(sql);
stmt.setString(1,username.getText());
stmt.setString(2,password.getText());
rs=stmt.executeQuery();
if(rs.next()){
//JOptionPane.showMessageDialog(null, "username and pasword correct");
JfrmInsertUpdateSearch s =new JfrmInsertUpdateSearch();
s.setVisible(true);
setVisible(false);
}
else{JOptionPane.showMessageDialog(null, "username and pasword incorrect");}
}
catch(Exception e){JOptionPane.showMessageDialog(null,e);}
}