示例#1
0
  /** loading the JDBC driver */
  private void loadJdbcDriver() {
    try {
      Class.forName(driver);
    } catch (ClassNotFoundException e) {
      e.printStackTrace();
      System.exit(1);
    }

    System.out.println("driver loaded");
  }
示例#2
0
  /** close the connection */
  public void closeConnection() {
    try {
      connection.close();
    } catch (SQLException e) {
      e.printStackTrace();
      System.exit(1);
    }

    System.out.println("\nconnection closed");
  }
示例#3
0
  /** opening the connection */
  private void openConnection() {
    try {
      connection = DriverManager.getConnection(getUrl(), user, password);
      ((org.postgresql.PGConnection) connection)
          .addDataType("geometry", org.postgis.PGgeometry.class);
      ((org.postgresql.PGConnection) connection).addDataType("box3d", org.postgis.PGbox3d.class);
      ((org.postgresql.PGConnection) connection).addDataType("box2d", org.postgis.PGbox2d.class);

    } catch (SQLException e) {
      e.printStackTrace();
      System.exit(1);
    }

    System.out.println("connection opened");
  }