Skip to content

Instantly share code, notes, and snippets.

@Mahkul
Created April 9, 2011 13:02

Revisions

  1. Mahkul created this gist Apr 9, 2011.
    35 changes: 35 additions & 0 deletions BookShelf.java
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    package database;

    import java.sql.*;

    public class BookDatabase {

    private String user = "";
    private String password = "";
    static String url = "jdbc:odbc:Books";

    static Connection link;
    static Statement statement;
    static ResultSet results;

    public BookDatabase() {

    try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

    } catch(java.lang.ClassNotFoundException e) {
    System.err.print("ClassNotFoundException: ");
    System.err.println(e.getMessage());
    }

    try {
    link = DriverManager.getConnection(url, user, password);
    statement = link.createStatement();

    } catch(SQLException ex) {
    System.err.println("SQLException: " + ex.getMessage());
    }

    }

    }