Initial Commit
This commit is contained in:
8
Source Code/Lab8/.idea/.gitignore
generated
vendored
Normal file
8
Source Code/Lab8/.idea/.gitignore
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Datasource local storage ignored files
|
||||
/../../../../../../../:\ProgrammingProjects\JavaProjects\JavaYear1\CS1103\Lab8\.idea/dataSources/
|
||||
/dataSources.local.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
7
Source Code/Lab8/.idea/codeStyles/Project.xml
generated
Normal file
7
Source Code/Lab8/.idea/codeStyles/Project.xml
generated
Normal file
@ -0,0 +1,7 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<code_scheme name="Project" version="173">
|
||||
<ScalaCodeStyleSettings>
|
||||
<option name="MULTILINE_STRING_CLOSING_QUOTES_ON_NEW_LINE" value="true" />
|
||||
</ScalaCodeStyleSettings>
|
||||
</code_scheme>
|
||||
</component>
|
5
Source Code/Lab8/.idea/codeStyles/codeStyleConfig.xml
generated
Normal file
5
Source Code/Lab8/.idea/codeStyles/codeStyleConfig.xml
generated
Normal file
@ -0,0 +1,5 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<state>
|
||||
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
|
||||
</state>
|
||||
</component>
|
114
Source Code/Lab8/.idea/dataSources/86582d0b-962d-4a8e-9b6b-40b421e02563.xml
generated
Normal file
114
Source Code/Lab8/.idea/dataSources/86582d0b-962d-4a8e-9b6b-40b421e02563.xml
generated
Normal file
@ -0,0 +1,114 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<dataSource name="MariaDB - ishoebot@cs1103.cs.unb.ca">
|
||||
<database-model serializer="dbm" dbms="MARIADB" family-id="MARIADB" format-version="4.20">
|
||||
<root id="1">
|
||||
<ServerVersion>5.5.65</ServerVersion>
|
||||
<DefaultEngine>InnoDB</DefaultEngine>
|
||||
<DefaultTmpEngine>InnoDB</DefaultTmpEngine>
|
||||
<DefaultCasing>exact</DefaultCasing>
|
||||
</root>
|
||||
<schema id="2" parent="1" name="Ch01_Problems">
|
||||
<Collation>latin1_swedish_ci</Collation>
|
||||
</schema>
|
||||
<schema id="3" parent="1" name="Ch01_Text">
|
||||
<Collation>latin1_swedish_ci</Collation>
|
||||
</schema>
|
||||
<schema id="4" parent="1" name="Ch02_DealCo">
|
||||
<Collation>latin1_swedish_ci</Collation>
|
||||
</schema>
|
||||
<schema id="5" parent="1" name="Ch02_InsureCo">
|
||||
<Collation>latin1_swedish_ci</Collation>
|
||||
</schema>
|
||||
<schema id="6" parent="1" name="Ch02_SaleCo">
|
||||
<Collation>latin1_swedish_ci</Collation>
|
||||
</schema>
|
||||
<schema id="7" parent="1" name="Ch02_TinyCollege">
|
||||
<Collation>latin1_swedish_ci</Collation>
|
||||
</schema>
|
||||
<schema id="8" parent="1" name="Ch03_AviaCo">
|
||||
<Collation>latin1_swedish_ci</Collation>
|
||||
</schema>
|
||||
<schema id="9" parent="1" name="Ch03_BeneCo">
|
||||
<Collation>latin1_swedish_ci</Collation>
|
||||
</schema>
|
||||
<schema id="10" parent="1" name="Ch03_CheapCo">
|
||||
<Collation>latin1_swedish_ci</Collation>
|
||||
</schema>
|
||||
<schema id="11" parent="1" name="Ch03_CollegeQue">
|
||||
<Collation>latin1_swedish_ci</Collation>
|
||||
</schema>
|
||||
<schema id="12" parent="1" name="Ch03_CollegeTry">
|
||||
<Collation>latin1_swedish_ci</Collation>
|
||||
</schema>
|
||||
<schema id="13" parent="1" name="Ch03_CollegeTry2">
|
||||
<Collation>latin1_swedish_ci</Collation>
|
||||
</schema>
|
||||
<schema id="14" parent="1" name="Ch03_InsureCo">
|
||||
<Collation>latin1_swedish_ci</Collation>
|
||||
</schema>
|
||||
<schema id="15" parent="1" name="Ch03_Museum">
|
||||
<Collation>latin1_swedish_ci</Collation>
|
||||
</schema>
|
||||
<schema id="16" parent="1" name="Ch03_NoComp">
|
||||
<Collation>latin1_swedish_ci</Collation>
|
||||
</schema>
|
||||
<schema id="17" parent="1" name="Ch03_Relational_DB">
|
||||
<Collation>latin1_swedish_ci</Collation>
|
||||
</schema>
|
||||
<schema id="18" parent="1" name="Ch03_SaleCo">
|
||||
<Collation>latin1_swedish_ci</Collation>
|
||||
</schema>
|
||||
<schema id="19" parent="1" name="Ch03_StoreCo">
|
||||
<Collation>latin1_swedish_ci</Collation>
|
||||
</schema>
|
||||
<schema id="20" parent="1" name="Ch03_Theatre">
|
||||
<Collation>latin1_swedish_ci</Collation>
|
||||
</schema>
|
||||
<schema id="21" parent="1" name="Ch03_TinyCollege">
|
||||
<Collation>latin1_swedish_ci</Collation>
|
||||
</schema>
|
||||
<schema id="22" parent="1" name="Ch03_TransCo">
|
||||
<Collation>latin1_swedish_ci</Collation>
|
||||
</schema>
|
||||
<schema id="23" parent="1" name="Ch03_VendingCo">
|
||||
<Collation>latin1_swedish_ci</Collation>
|
||||
</schema>
|
||||
<schema id="24" parent="1" name="Ch04_Clinic">
|
||||
<Collation>latin1_swedish_ci</Collation>
|
||||
</schema>
|
||||
<schema id="25" parent="1" name="Ch04_CollegeTry">
|
||||
<Collation>latin1_swedish_ci</Collation>
|
||||
</schema>
|
||||
<schema id="26" parent="1" name="Ch04_PartCo">
|
||||
<Collation>latin1_swedish_ci</Collation>
|
||||
</schema>
|
||||
<schema id="27" parent="1" name="Ch04_ShortCo">
|
||||
<Collation>latin1_swedish_ci</Collation>
|
||||
</schema>
|
||||
<schema id="28" parent="1" name="Ch04_TinyCollege">
|
||||
<Collation>latin1_swedish_ci</Collation>
|
||||
</schema>
|
||||
<schema id="29" parent="1" name="Ch04_TinyCollege_Alt">
|
||||
<Collation>latin1_swedish_ci</Collation>
|
||||
</schema>
|
||||
<schema id="30" parent="1" name="Ch07_ConstructCo">
|
||||
<Collation>latin1_swedish_ci</Collation>
|
||||
</schema>
|
||||
<schema id="31" parent="1" name="Ch07_Fact">
|
||||
<Collation>latin1_swedish_ci</Collation>
|
||||
</schema>
|
||||
<schema id="32" parent="1" name="Ch07_LargeCo">
|
||||
<Collation>latin1_swedish_ci</Collation>
|
||||
</schema>
|
||||
<schema id="33" parent="1" name="Ch07_SaleCo">
|
||||
<Collation>latin1_swedish_ci</Collation>
|
||||
</schema>
|
||||
<schema id="34" parent="1" name="information_schema">
|
||||
<Collation>utf8_general_ci</Collation>
|
||||
</schema>
|
||||
<schema id="35" parent="1" name="ishoebot">
|
||||
<Current>1</Current>
|
||||
<Collation>latin1_swedish_ci</Collation>
|
||||
</schema>
|
||||
</database-model>
|
||||
</dataSource>
|
6
Source Code/Lab8/.idea/discord.xml
generated
Normal file
6
Source Code/Lab8/.idea/discord.xml
generated
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DiscordProjectSettings">
|
||||
<option name="show" value="PROJECT_FILES" />
|
||||
</component>
|
||||
</project>
|
10
Source Code/Lab8/.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
10
Source Code/Lab8/.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
@ -0,0 +1,10 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="DuplicatedCode" enabled="true" level="WEAK WARNING" enabled_by_default="true">
|
||||
<Languages>
|
||||
<language minSize="102" name="Java" />
|
||||
</Languages>
|
||||
</inspection_tool>
|
||||
</profile>
|
||||
</component>
|
9
Source Code/Lab8/.idea/libraries/mysql_connector_java.xml
generated
Normal file
9
Source Code/Lab8/.idea/libraries/mysql_connector_java.xml
generated
Normal file
@ -0,0 +1,9 @@
|
||||
<component name="libraryTable">
|
||||
<library name="mysql-connector-java">
|
||||
<CLASSES>
|
||||
<root url="jar://C:/Program Files (x86)/MySQL/Connector J 8.0/mysql-connector-java-8.0.23.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</component>
|
6
Source Code/Lab8/.idea/misc.xml
generated
Normal file
6
Source Code/Lab8/.idea/misc.xml
generated
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
8
Source Code/Lab8/.idea/modules.xml
generated
Normal file
8
Source Code/Lab8/.idea/modules.xml
generated
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/Lab8.iml" filepath="$PROJECT_DIR$/Lab8.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
7
Source Code/Lab8/.idea/sqldialects.xml
generated
Normal file
7
Source Code/Lab8/.idea/sqldialects.xml
generated
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="SqlDialectMappings">
|
||||
<file url="file://$PROJECT_DIR$/src/Question1.java" dialect="MariaDB" />
|
||||
<file url="PROJECT" dialect="MariaDB" />
|
||||
</component>
|
||||
</project>
|
12
Source Code/Lab8/Lab8.iml
Normal file
12
Source Code/Lab8/Lab8.iml
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="mysql-connector-java" level="project" />
|
||||
</component>
|
||||
</module>
|
BIN
Source Code/Lab8/out/production/Lab8/Question1.class
Normal file
BIN
Source Code/Lab8/out/production/Lab8/Question1.class
Normal file
Binary file not shown.
BIN
Source Code/Lab8/out/production/Lab8/Question2.class
Normal file
BIN
Source Code/Lab8/out/production/Lab8/Question2.class
Normal file
Binary file not shown.
55
Source Code/Lab8/src/Question1.java
Normal file
55
Source Code/Lab8/src/Question1.java
Normal file
@ -0,0 +1,55 @@
|
||||
import java.sql.CallableStatement;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class Question1 {
|
||||
public static void main(String[] args) {
|
||||
Question1 question1 = new Question1();
|
||||
Connection conn = question1.openConnection();
|
||||
Scanner sc = new Scanner(System.in);
|
||||
System.out.print("What is the name of the student?: ");
|
||||
String studentName = sc.nextLine();
|
||||
System.out.print("What is the email address of the student?: ");
|
||||
String emailAddress = sc.nextLine();
|
||||
System.out.print("What is the high school average of the student?: ");
|
||||
String highSchoolAverage = sc.nextLine();
|
||||
try {
|
||||
String query = "{CALL AcceptStudent(?, ?, ?)}";
|
||||
CallableStatement statement = conn.prepareCall(query);
|
||||
statement.setString(1, studentName);
|
||||
statement.setString(2, emailAddress);
|
||||
statement.setString(3, highSchoolAverage);
|
||||
statement.executeQuery();
|
||||
|
||||
} catch (SQLException sqlException) {
|
||||
System.err.println(sqlException.getMessage());
|
||||
}
|
||||
System.out.println(studentName + " with email address: " + emailAddress + " and a high school average of: " + highSchoolAverage + " added");
|
||||
question1.closeConnection(conn);
|
||||
}
|
||||
|
||||
|
||||
private Connection openConnection() {
|
||||
final String url = "jdbc:mysql://cs1103.cs.unb.ca:3306/ishoebot";
|
||||
final String user = "ishoebot";
|
||||
final String password = "k7FOLH5B";
|
||||
Connection conn = null;
|
||||
try {
|
||||
conn = DriverManager.getConnection(url, user, password);
|
||||
}
|
||||
catch (Exception exception) {
|
||||
System.err.printf("Couldn't open a connection: (%s)", exception.getMessage());
|
||||
}
|
||||
return conn;
|
||||
}
|
||||
private void closeConnection(Connection conn) {
|
||||
try {
|
||||
conn.close();
|
||||
}
|
||||
catch (Exception exception) {
|
||||
System.err.printf("Couldn't close connection: (%s)", exception.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
48
Source Code/Lab8/src/Question2.java
Normal file
48
Source Code/Lab8/src/Question2.java
Normal file
@ -0,0 +1,48 @@
|
||||
import java.sql.*;
|
||||
|
||||
public class Question2 {
|
||||
public static void main(String[] args) {
|
||||
if(args.length < 1) {
|
||||
System.err.println("Usage: Question2 <StudentID>");
|
||||
System.exit(-1);
|
||||
}
|
||||
Question2 question2 = new Question2();
|
||||
Connection conn = question2.openConnection();
|
||||
String studentID = args[0];
|
||||
try {
|
||||
String query = "{CALL studentTranscript(?)}";
|
||||
CallableStatement statement = conn.prepareCall(query);
|
||||
statement.setString(1, studentID);
|
||||
ResultSet rs = statement.executeQuery();
|
||||
while(rs.next()) {
|
||||
String row = rs.getString(1) + ": " + rs.getString(2);
|
||||
System.out.println(row);
|
||||
}
|
||||
} catch (SQLException sqlException) {
|
||||
System.err.println(sqlException.getMessage());
|
||||
}
|
||||
question2.closeConnection(conn);
|
||||
|
||||
}
|
||||
private Connection openConnection() {
|
||||
final String url = "jdbc:mysql://cs1103.cs.unb.ca:3306/ishoebot";
|
||||
final String user = "ishoebot";
|
||||
final String password = "k7FOLH5B";
|
||||
Connection conn = null;
|
||||
try {
|
||||
conn = DriverManager.getConnection(url, user, password);
|
||||
}
|
||||
catch (Exception exception) {
|
||||
System.err.printf("Couldn't open a connection: (%s)", exception.getMessage());
|
||||
}
|
||||
return conn;
|
||||
}
|
||||
private void closeConnection(Connection conn) {
|
||||
try {
|
||||
conn.close();
|
||||
}
|
||||
catch (Exception exception) {
|
||||
System.err.printf("Couldn't close connection: (%s)", exception.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user