import java.sql.*; public class LabProgram { // Create a connection to a sqlite in-memory
Question:
import java.sql.*;
public class LabProgram {
// Create a connection to a sqlite in-memory database
// Returns Connection object
public static Connection createConnection() {
// YOUR CODE HERE
// Use connection string "jdbc:sqlite::memory:"
}
// Create Horse table
// Parameter conn is database connection created in createConnection()
public static void createTable(Connection conn) {
// YOUR CODE HERE
}
// Insert row into Horse table using a parameterized query
// Parameter conn is database connection created in createConnection()
// Parameters id, name, breed, height, and birthDate contain values to be inserted
public static void insertHorse(Connection conn, int id, String name, String breed, double height, String birthDate) {
// YOUR CODE HERE
}
// Select and print all rows of Horse table
// Parameter conn is database connection created in createConnection()
public static void selectAllHorses(Connection conn) {
// YOUR CODE HERE
}
// DO NOT MODIFY main
public static void main(String[] args) {
// Create connection to sqlite in-memory database
Connection conn = createConnection();
// Create Horse table
createTable(conn);
// Insert row into Horse table
insertHorse(conn, 1, "Babe", "Quarter Horse", 15.3, "2015-02-10");
// Select and print all Horse table rows
selectAllHorses(conn);
}
}
Modern Database Management
ISBN: 978-0133544619
12th edition
Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi