1
votes

I am trying to create an executible JAR file that has my database self-contained as a CSV file (the point is that if I share the program to another computer, that computer does not need to download MySQL in order to access the information in the database).

I have imported H2 libraries, so that I can convert the CSV into a ResultSet. Is there a way I can integrate SQL statements to manipulate the ResultSet without having to set up a connection to a database?

This is what I have so far, with a connection to a database:

// This is where I want to retrieve the data (from the CSV), 
// but the only way I know how to run SQL requires that the data is 
// retrieved from the MySQL database connection. 

   ResultSet rs = new Csv().read("file.csv", null, null);
    
// This is the traditional way of executing an SQL query statement

   Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/db","root","password");
    
   Statement stmt = con.createStatement(); // Another way to create the statement?

   rs = stmt.executeQuery(sql);