Ok I am trying to connect to a mysql db with the following code. I tried looking at documentation but I am just having no luck what so ever.
Here is the code:
public class TESTSQL { static final String JDBC_DRIVER = "com.mysql.jdbc.Driver"; static final String DB_URL = "jdbc:mysql://SLibraryDev.db.996****.hostedresource.com"; static final String USER = "SLD"; static final String PASS = "F11!"; public static void main(String[] args) { Connection conn = null; Statement stmt = null; try { // STEP 2: Register JDBC driver Class.forName(JDBC_DRIVER); // STEP 3: Open a connection System.out.println("Connecting to database..."); conn = DriverManager.getConnection(DB_URL, USER, PASS); ... } This is the error I am getting :
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver at java.net.URLClassLoader$1.run(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Unknown Source) When I comment out "Class.forName(JDBC_DRIVER)" and run it I get this error:
java.sql.SQLException: No suitable driver found for jdbc:mysql://SLibraryDev.db.996****.hostedresource.com at java.sql.DriverManager.getConnection(Unknown Source) at java.sql.DriverManager.getConnection(Unknown Source) What I thought I needed to do was to download and run this : http://dev.mysql.com/downloads/connector/j/ which I did but it seemed like something was wrong with this installer...It seemed like it never finished, like it cut out in the middle of the process. Anyone have any ideas on what I need to do.