Setting Up MariaDB To Match hoare.cs.umsl.edu


Step 1: Install MariaDB    (I put it in directory MariaDB with root password "smith").



Setting up the account.

C:\MariaDB\bin>mysql --user=root --password=smith Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 7 Server version: 10.1.19-MariaDB mariadb.org binary distribution Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> create database cs4010; Query OK, 1 row affected (0.00 sec) MariaDB [(none)]> CREATE USER cs4010; Query OK, 0 rows affected (0.00 sec) MariaDB [cs4010]> SET PASSWORD FOR cs4010 = PASSWORD('cs4010'); Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> GRANT ALL PRIVILEGES ON cs4010.* to cs4010; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> exit; Bye

Working With user cs4010.

C:\MariaDB\bin>mysql --user=cs4010 --password=cs4010 --database=cs4010 Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 13 Server version: 10.1.19-MariaDB mariadb.org binary distribution Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [cs4010]> CREATE TABLE cs4010.student -> ( -> student_id int NOT NULL AUTO_INCREMENT, -> name varchar(255) NOT NULL, -> year varchar(20), -> test int, -> PRIMARY KEY (student_id) -> ) -> ; Query OK, 0 rows affected (0.42 sec) MariaDB [cs4010]> insert into student (name,year,test) values ("Joe Jones","Senior",85); Query OK, 1 row affected (0.36 sec) MariaDB [cs4010]> select * from student; +------------+-----------+--------+------+ | student_id | name | year | test | +------------+-----------+--------+------+ | 1 | Joe Jones | Senior | 85 | +------------+-----------+--------+------+ 1 row in set (0.02 sec) MariaDB [cs4010]>

Testing the connection with testmariaDB.java.

Download mariadb-java-client-1.5.5.jar to your jre and jdk lib\ext directories C:\MyCourse\CS4010>javac testmariaDB.java C:\MyCourse\CS4010>java testmariaDB Connecting to database... Creating statement... SELECT name, year, test FROM student; Name: Joe Jones Year: Senior Grade: 85 Goodbye! C:\MyCourse\CS4010>