Re: Connector/J installation
Posted by: Filipe Silva
Date: January 18, 2018 05:33AM

Hi Jim,

Unless you choose to use a build manager, such as maven, which handles all dependencies on your behalf, it is usually better to keep your jars close to your project, at least while you are developing it.

So, I would recommend moving the Connector/J jar (the file you mentioned) to a directory in your project root ('lib' or 'jars'... whatever you prefer). All your code goes into the 'src' directory and compiled classes into 'bin' or 'classes' (again, whatever you prefer). If using Eclipse you can set all this in the project properties window.

To run your code you can do either one:

- If you are using Eclipse (or any other IDE) after setting up your project basics (name, location, directories, etc) you just need to open the 'lib' directory, right click on the file 'mysql-connector-java-5.1.45-bin.jar', Build Path -> Add to Build Path, then press on play button in the toolbar.

- If you want to use the command line you first need to run 'javac' to compile the code (use option -d set the destination for the class files) and then start your program with 'java'. You could set the system variable CLASSPATH pointing to the 'lib' and 'bin' directories before running these commands, but the preferred way would be to run them with the option "-cp"; "-cp lib" in 'javac' and "-cp lib;bin" with "java".

IHTH

Options: ReplyQuote


Subject
Written By
Posted
January 18, 2018 12:18AM
Re: Connector/J installation
January 18, 2018 05:33AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.