I have a mac, and im trying to connect to mysql on localhost with java, however, it wont, and ive been good and followed the rules, but it wont work :-(
paulio macmurray wrote:the error shown is :Exception: com.mysql.jdbc.Driver
i also made a slightly different script which is below. The error message in that is my own "Cannot connect to database"
Just print the exact error you are getting by printing it (ie: e.printStackTrace()) inside the catch block and post that error here? You have the JDBC Driver in your classpath?
Just a note to let you know i managed to get the script to work, but only by dumping the connection file in the same directory as the java file, and then javac ing it in a command prompt.
paulio macmurray wrote:Just a note to let you know i managed to get the script to work, but only by dumping the connection file in the same directory as the java file, and then javac ing it in a command prompt.
If you set the classpath properly (which should includes the required jar files and the class files you are executing) no need to have them in the same place.
Is there anyway to avoid this in netbeans?
To run this inside the IDEyou should set those jars in the build path of the IDE.