I have an old program from college that I am trying to get to work so I can adapt and use it for something new. This program uses a MySQL database, and using the JDBC framework I add data to my DB. I am using Xampp/PHPMyAdmin to support the database in a web browser format on macOS 11.1.
When I try to compile the driver program for the program using "javac -cp mysql-driver.jar Driver.java", it throws a "cannot find symbol" error for one of the classes being used.
When I tried to compile the driver program with the regular "javac Driver.java", it compiles, and it runs with the "java Driver" command. However, after running it like this, when it comes time to connect to the database it throws a "ClassNotFoundException: com.mysql.jdbc.Driver."
Here is a code snippet for Connecting to the Database:
try{
Class.forName("com.mysql.jdbc.Driver");
String dbconn = "jdbc:mysql://" + db.getHostName() +
"/" + db.getDBName();
conn = DriverManager.getConnection(dbconn, db.getUsername(), db.getPassword());
stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
String query1 = "select * from " + db.getTableName();
rset = stmt.executeQuery(query1);
.
.
.
}
I know it needs the driver file to be in the class path so it can actually connect to the DB, but it isn't compiling with the driver file in the class path.