Skip to content

Latest commit

 

History

History
70 lines (56 loc) · 3.27 KB

File metadata and controls

70 lines (56 loc) · 3.27 KB

Database Information

CSC205, CSC220, and CSC240 are not database courses, but we will briefly cover databases if we have time. We will cover a very small subset of SQL - CREATE TABLE, INSERT, SELECT, and possibly UPDATE - just enough to be able to do something non-trivial in our programs.

General Database Links

SQL Tutorials

Other SQL links

JDBC

Setting up SQLite in Eclipse

  1. Download the SQLite jar
  2. Install the JAR file in your project.
  3. Left click on your project and select Build Path -> Configure Build Path
  4. Click the Libraries tab and click "Add External JAR"
  5. Navigate to the directory you downloaded the SQLite JAR file and select it.
  6. Click OK
  7. If the installation worked, try to execute the class below. It should state that it made the connection correctly.
import java.sql.Connection;
import java.sql.DriverManager; import java.sql.SQLException;

public class SQLiteTest {

    public static void main(String args[]) {
        try {
            Class.forName("org.sqlite.JDBC");
        } catch (ClassNotFoundException e1) {
            e1.printStackTrace();
        }
        Connection conn = null;
        try {
                conn = DriverManager.getConnection("jdbc:sqlite:csc205.db");
                System.out.println("Opened database connection!");
        } catch (SQLException e) {
            e.printStackTrace();
            System.out.println(e.getClass().getName() + ": " + e.getMessage());
        }
        finally {
            if (conn != null) {
                try {
                    conn.close();
                } catch (SQLException e) {
                    e.printStackTrace();
                    System.out.println(e.getMessage());
                }
            }
        }
    }
}