final exam Code Flashcards

1
Q

Change the order

A

ORDER BY <field> DESC (default is ascending)</field>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

counting

A

SELECT pub_id, COUNT( * )
FROM titles
GROUP BY pub_id
HAVING COUNT( * ) > 5;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Insert Statement

A

INSERT INTO <table>
VALUES (v1, v2, …);

INSERT INTO <table>(field1, field2,…)
VALUES (v1, v2, …);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Update Statement

A

UPDATE <table name>
SET <field> = <value>
WHERE <logical></logical></value></field>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Delete Statement

A

DELETE FROM <table name>
WHERE <logical></logical>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Inner join

A

From <table> AS <letter> INNER JOIN <table2> as <letter2> ON <use></use></letter2></table2></letter>

SELECT Name, Language
FROM Country AS c INNER JOIN CountryLanguage AS cl ON c.Code = cl.CountryCode

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

pom file

A

<dependencies>
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.39.4.0</version>
</dependency>
</dependencies>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

JDBC imports and package

A

package edu.psu.bd.cs.akv5335.<name>;
import java.sql.*;
import java.util.Scanner;</name>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

creating a connection code

A
  1. create a connection
    Connection connection;
    Scanner scanner = new Scanner(System.in);
  2. try statement (driver manager, prepared statement, result set, execute query, close connections)
    try
    {
    connection = DriverManager.getConnection(“jdbc:sqlite:\C…”);

PreparedStatement statement = connection.prepareStatement(“write query, use ? for the thing we don’t have”);

ResultSet set;

do
{
get what you need from user
statement.set<user>(1,varName)
set = statement.executeQuery();</user>

//to print out a certain part of the result, do set.getString(“what you want”);

//after do-while
set.close();
connection.close();

  1. catch statement
    catch(SQLException e)
    {
    e.printStackTrace();
    }
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

web application code

A

@RestController
public class className
{
@GetMapping(path =”/classNameObject”)
public className methodName(@RequestParam(name = “word”) String word)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly