When I run code that uses a sql driver for jbdc it works on eclipse. This is after I went into the project properties and added the external jar. However when I run the following from the command line it fails.
java -version
java version "1.8.0_25"
javac sql_stuff.java
java sql_stuff -classpath conn.jar
java.sql.SQLException: No suitable driver found for jdbc:mysql://...
Same with -cp
javac sql_stuff.java
java sql_stuff -cp conn.jar
In Eclipse all I had to do is go project > Properties > Java Build Path > Libraries and add the jar file.
Edit
Got it finally running with
java -cp .:conn.jar sqlstuff
Java seems to need to 're-add' a class path (even though it was '.' !!!) otherwise it wouldn't find the class. Also you have to use : as a separator (or sometimes ; ), god knows why. Hopefully this will help others when they stumble across issues.
-cpon thejavacommand, not thejavaccommand. The driver is not needed during compilation, but it is needed at run-time.-cpand its argument before the class name. By the way, class names should not have underscores, and should start with a capital letter, likeSqlStuff.