Updated May 19, 2026
Overview
This documentation applies to some projects, notably CISS-110 Project 8, and CISS-111 Projects 5 and 8. It is also a basic setup for generic JDBC connectivity to a MySQL database.
Setup
You must download the MySQL JDBC jar file from https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-j-9.7.0.zip and then extract the contents of the zip file. You only need the mysql-connector-j-9.7.0.jar file.
After creating your IntelliJ project:
- Select File then Project Structure.
- Select Modules from the left menu.
- Select Dependencies.
- Select +, then JARs or Directories, browse to the MySQL jar, select it, and select Open.
The JAR is now integrated with your project. Here is some supporting code to include in your project. This will provide the basic database connectivity you will need.
The DBSupport file
This piece of code provides the basic support for JDBC connectivity to the MySQL databases. This is provided to ease entry into accessing databases from Java. Spend a bit of time with the code and you will find it to be readily self-explanatory.
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class DBSupport {
public static Connection getDBConn() {
Connection mdb;
String userName="GETFROMINSTRUCTOR", password="GETFROMINSTRUCTOR";
String url = "jdbc:mysql://crammit.in:7070/ciss111p5";
try {
mdb = DriverManager.getConnection(url +
"?user="+ userName + "&password=" + password);
return mdb;
} catch (SQLException ex) {
// handle any errors
System.err.println("SQLException: " + ex.getMessage());
System.err.println("SQLState: " + ex.getSQLState());
System.err.println("VendorError: " + ex.getErrorCode());
return null;
}
}
public static boolean getMysqlStatus(Connection mdb) {
if ( mdb != null )
try {
return !mdb.isClosed();
} catch (SQLException e) {
return false;
}
return false;
}
public static void closeDB(Connection mdb) {
try {
if ( mdb != null && !mdb.isClosed() )
mdb.close();
} catch (SQLException e) {
System.err.println("Failed closing MySQL connection.");
}
}
}
CISS-110 Code
These are pieces of code to get you started on the specified projects for CISS-110.
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
public class Project8_lastname {
public static void main(String[] args) throws SQLException {
Connection mydb = DBSupport.getDBConn();
ResultSet results;
// test query for project 8
String query = "select name, inode, pinode, mode, type from entries order by rand() limit 1;";
/* this is some test code for you! */
boolean status = DBSupport.getMysqlStatus(mydb);
System.out.println("DB status is " + (status ? "GOOD!" :"BAD!"));
if (status) {
results = mydb.createStatement().executeQuery(query);
while (results.next()) {
String name = results.getString("name");
long inode = results.getLong("inode"), pinode = results.getLong("pinode");
int mode = results.getInt("mode");
String type = results.getString("type");
System.out.println("Got name -> " + name
+ "\nGot inode -> " + inode
+ "\nGot pinode -> " + pinode
+ "\nGot mode -> " + mode
+ "\nGot type -> " + type);
}
}
/* END test code */
DBSupport.closeDB(mydb);
}
}
CISS-111 Code
These are pieces of code to get you started on the specified projects for CISS-111. The first for Project 5.
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
public class Project5_lastname {
public static void main(String[] args) throws SQLException {
Connection mydb = DBSupport.getDBConn();
ResultSet results;
// test query for project 5
String query = "select word from wordsToInsert order by rand() limit 1;";
/* this is some test code for you! */
boolean status = DBSupport.getMysqlStatus(mydb);
System.out.println("DB status is " + (status ? "GOOD!" :"BAD!"));
if (status) {
results = mydb.createStatement().executeQuery(query);
while (results.next())
System.out.println("Got word -> " + results.getString("word"));
}
/* END test code */
DBSupport.closeDB(mydb);
}
}
And another for Project 8.
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
public class Project8_lastname {
public static void main(String[] args) throws SQLException {
Connection mydb = DBSupport.getDBConn();
ResultSet results;
// test query for project 8
String query = "select path,type from pathnames order by rand() limit 1;";
/* this is some test code for you! */
boolean status = DBSupport.getMysqlStatus(mydb);
System.out.println("DB status is " + (status ? "GOOD!" :"BAD!"));
if (status) {
results = mydb.createStatement().executeQuery(query);
while (results.next())
System.out.println("Got path -> " + results.getString("path")
+ " as " + results.getString("type"));
}
/* END test code */
DBSupport.closeDB(mydb);
}
}
Credentials
You will be sent the credentials for the DBsupport.java file as an announcement. Once you have them, plug them into the code and compile it as is. It should compile successfully with a test of the MySQL database. If connectivity is good, you will see something like
CISS-110 Project 8
DB status is GOOD! Got name -> ZONE_DMA32 Got inode -> 691328 Got pinode -> 681782 Got mode -> 644 Got type -> f
CISS-111 Project 5
DB status is GOOD! Got word -> MAIN
CISS-111 Project 8
DB status is GOOD! Got path -> /home/julie/fiber as D
Otherwise, you will get some kind of error like the one shown below.
SQLException: Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. SQLState: 08S01 VendorError: 0 DB status is BAD!
This may not be the only kind of error received. There are so many ways to fail a database connection. As always, if you’ve confirmed the link and credentials and the database connection continues to fail, reach out to your instructor immediately for resolution.