Arlon's CSUMB Intro to Database Systems CST-363 Module 4 Learning Journal #4/#20 for the week Wed 05/19-Tues 05/25, year 2021
Arlon's CSUMB Intro to Database Systems CST-363 Module 4 Learning Journal #4/#20 for the week Wed 05/19-Tues 05/25, year 2021 Prompt for week 4: When coding a Java program that will perform a SELECT statement that return multiple rows, what are the steps needed? The first is to make a connection to the database and the last is close the connection. What are the other steps? // Write the query as a string in MySQL String sql_query_string=" SELECT * FROM `everything` where name like ? ; -- (etc.)"; // Make a prepared statement with the string PreparedStatement preparedStatement = connection.prepareStatement( sql_query_string); // Replace the ?'s in the prepared statement with setString() and setInt() preparedStatement.setString(1, name.trim()+"%"); // Execute the query with MySQL: ResultSet resultSet=preparedStatement.executeQuery(); // Iterate the rows, get each column: while (resultSet.next()) { // Row details acc...