Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Complete the java sql code Complete the specified methods and be sure to report your LMS ID to the instructor. SQLDatabase.java import java. sql.*; SQL

Complete the java sql code

image text in transcribed
Complete the specified methods and be sure to report your LMS ID to the instructor. SQLDatabase.java import java. sql.*; SQL Database Class Each instance is capable of connecting to and operating * upon a separate database. In other words, using multiple databases * concurrently. Each instance maintains the Connection and creates a Statement. 8 SQLExceptions are handled and methods return either null or false if the 9 * operation was unsuccessful 10 11 @author Dr. Gerald Cohen, Ph.D. Copyright (c) 2023, 2024 12 public class SQLDatabase { // Instance data for the database private String databaseType = "jdbc:sqlite:"; 17 private String databaseURL; 18 / /private DatabaseMetaData metadata; 19 private Connection connection; // Database connection 20 private Statement statement; // Statement for general use 21 22 1* * 23 * Use the specified database type, 'jdbc:sqlite:' or 'jdbc:hsqldb: ' 24 25 @param databaseType 26 27 public SQLDatabase (String databaseType) { 28 this . databaseType = databaseType; 29 } 30 31 32 * Connect to a database having the specified URL. User names and passwords 33 * are not used for SQLite and HSQLDB 34 35 * @param databaseURL the database path name 36 * @param user name or "" 37 * @param password or "" 38 * @return connection or null if it failed and print exception message 39 40 public Connection connectToDatabase (String databaseURL, String user, String password) { 41 42 43 44 this. statement = createStatement ( ) ; 45 return connection; 46 47 * Create a Statement for external use * @return null if not successful private Statement createStatement ( ) { * Return metadata about the current connection * @return metadata or null if not successful public DatabaseMetaData getMetaData( ) { 68 69 70 * * 71 * Execute an SQL update using this object's sql statement. 72 73 * @param sql sql statement 74 @return true if successful 75 76 public boolean executeUpdate (String sql) { 77 78 79 80 81 82 CodeCheck Reset

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Mobile Communications

Authors: Jochen Schiller

2nd edition

978-0321123817, 321123816, 978-8131724262

More Books

Students also viewed these Programming questions