I have converted a java project ms access database to mysql and run it from localhost wamp server. Now I have connected the database to Netbeans java project. But I am not able to run the project. It is saying build failed. Is there any particular reason it is not working? Here's the code for the connection that I have made.
import java.awt.Dimension;
import java.awt.Toolkit;
import java.sql.Connection;
import java.sql.DriverManager;
public class Settings {
public static Dimension getScreenSize(){
Dimension d=Toolkit.getDefaultToolkit().getScreenSize();
return d;
}//getScreenSize() closed
public static Connection getDBConnection(){
Connection con;
try{
Class.forName("java.sql.Driver");
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/student?zeroDateTimeBehavior=convertToNull","root","root");
return con;
}catch(Exception ex){
return null;
}
}
}//class closed
I have made changes on other .java files that try to connect to database. For eg the login.java file has connection which I have changed:
public void actionPerformed(ActionEvent e) {
if (e.getSource() == btnLogin) {
try {
Class.forName("java.sql.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/student?zeroDateTimeBehavior=convertToNull","root","root");
Please suggest me.
The exception I am getting is:
Exception in thread "main" java.lang.NullPointerException
at javax.swing.ImageIcon.<init>(ImageIcon.java:217)
at Login.<init>(Login.java:36)
at Login.main(Login.java:90)
C:\Users\MyPc\AppData\Local\NetBeans\Cache\8.1\executor-snippets\run.xml:53: Java returned: 1
BUILD FAILED (total time: 1 second)