/** * Mangles the PostGIS URL to return the original PostGreSQL URL * * @param url String containing the url to be "mangled" * @return "mangled" string * @throws SQLException when a SQLException occurs */ protected String mangleURL(String url) throws SQLException { String myProgo = getProtoString(); if (url.startsWith(myProgo)) { return POSTGRES_PROTOCOL + url.substring(myProgo.length()); } else { throw new SQLException("Unknown protocol or subprotocol in url " + url); } }
/** * adds the JTS/PostGIS Data types to a PG 8.0+ Connection. * * @param pgconn The PGConnection object to add the types to * @throws SQLException when a SQLException occurs */ public static void addGISTypes80(PGConnection pgconn) throws SQLException { loadTypesAdder("80").addGT((Connection) pgconn, false); }
/** * Creates a postgresql connection, and then adds the PostGIS data types to * it calling addpgtypes() * * @param url the URL of the database to connect to * @param info a list of arbitrary tag/value pairs as connection arguments * @return a connection to the URL or null if it isnt us * @exception SQLException if a database access error occurs * * @see java.sql.Driver#connect * @see org.postgresql.Driver */ public java.sql.Connection connect(String url, Properties info) throws SQLException { url = mangleURL(url); Connection result = super.connect(url, info); typesAdder.addGT(result, useLW(result)); return result; }
/** * Check whether the driver thinks he can handle the given URL. * * @see java.sql.Driver#acceptsURL * @param url the URL of the driver * @return true if this driver accepts the given URL */ public boolean acceptsURL(String url) { try { url = mangleURL(url); } catch (SQLException e) { return false; } return super.acceptsURL(url); }
/** * Default constructor. * * This also loads the appropriate TypesAdder for our SQL Driver instance. * * @throws SQLException when a SQLException occurs */ public DriverWrapper() throws SQLException { super(); typesAdder = getTypesAdder(this); // The debug method is @since 7.2 if (super.getMajorVersion() > 8 || super.getMinorVersion() > 1) { logger.fine(this.getClass().getName() + " loaded TypesAdder: " + typesAdder.getClass().getName()); } }
/** * Creates a postgresql connection, and then adds the PostGIS data types to * it calling addpgtypes() * * @param url the URL of the database to connect to * @param info a list of arbitrary tag/value pairs as connection arguments * @return a connection to the URL or null if it isnt us * @exception SQLException if a database access error occurs * * @see java.sql.Driver#connect * @see org.postgresql.Driver */ public java.sql.Connection connect(String url, Properties info) throws SQLException { url = mangleURL(url); Connection result = super.connect(url, info); typesAdder.addGT(result, useLW(result)); return result; }
/** * Check whether the driver thinks he can handle the given URL. * * @see java.sql.Driver#acceptsURL * @param url the URL of the driver * @return true if this driver accepts the given URL */ public boolean acceptsURL(String url) { try { url = mangleURL(url); } catch (SQLException e) { return false; } return super.acceptsURL(url); }
/** * Default constructor. * * This also loads the appropriate TypesAdder for our SQL Driver instance. * * @throws SQLException when a SQLException occurs */ public DriverWrapper() throws SQLException { super(); typesAdder = getTypesAdder(this); // The debug method is @since 7.2 if (super.getMajorVersion() > 8 || super.getMinorVersion() > 1) { logger.fine(this.getClass().getName() + " loaded TypesAdder: " + typesAdder.getClass().getName()); } }
/** * adds the JTS/PostGIS Data types to a PG 7.2 Connection. * * @param pgconn The PGConnection object to add the types to * @throws SQLException when a SQLException occurs */ public static void addGISTypes72(org.postgresql.PGConnection pgconn) throws SQLException { loadTypesAdder("72").addGT((Connection) pgconn, false); }
/** * Mangles the PostGIS URL to return the original PostGreSQL URL * * @param url String containing the url to be "mangled" * @return "mangled" string * @throws SQLException when a SQLException occurs */ protected String mangleURL(String url) throws SQLException { String myProgo = getProtoString(); if (url.startsWith(myProgo)) { return POSTGRES_PROTOCOL + url.substring(myProgo.length()); } else { throw new SQLException("Unknown protocol or subprotocol in url " + url); } }
/** * adds the JTS/PostGIS Data types to a PG 8.0+ Connection. * * @param pgconn The PGConnection object to add the types to * @throws SQLException when a SQLException occurs */ public static void addGISTypes80(PGConnection pgconn) throws SQLException { loadTypesAdder("80").addGT((Connection) pgconn, false); }
protected static TypesAdder getTypesAdder(Driver d) throws SQLException { if (d.getMajorVersion() == 7) { if (d.getMinorVersion() >= 3) { if (ta74 == null) { ta74 = loadTypesAdder("74"); } return ta74; } else { if (ta72 == null) { ta72 = loadTypesAdder("72"); } return ta72; } } else { if (ta80 == null) { ta80 = loadTypesAdder("80"); } return ta80; } }
/** * adds the JTS/PostGIS Data types to a PG 7.3+ Connection. If you use * PostgreSQL jdbc drivers V8.0 or newer, those methods are deprecated due * to some class loader problems (but still work for now), and you may want * to use the method below instead. * * @param pgconn The PGConnection object to add the types to * @throws SQLException when a SQLException occurs * */ public static void addGISTypes(PGConnection pgconn) throws SQLException { loadTypesAdder("74").addGT((Connection) pgconn, false); }
/** * adds the JTS/PostGIS Data types to a PG 7.2 Connection. * * @param pgconn The PGConnection object to add the types to * @throws SQLException when a SQLException occurs */ public static void addGISTypes72(org.postgresql.PGConnection pgconn) throws SQLException { loadTypesAdder("72").addGT((Connection) pgconn, false); }
/** * adds the JTS/PostGIS Data types to a PG 7.3+ Connection. If you use * PostgreSQL jdbc drivers V8.0 or newer, those methods are deprecated due * to some class loader problems (but still work for now), and you may want * to use the method below instead. * * @param pgconn The PGConnection object to add the types to * @throws SQLException when a SQLException occurs * */ public static void addGISTypes(PGConnection pgconn) throws SQLException { loadTypesAdder("74").addGT((Connection) pgconn, false); }
protected static TypesAdder getTypesAdder(Driver d) throws SQLException { if (d.getMajorVersion() == 7) { if (d.getMinorVersion() >= 3) { if (ta74 == null) { ta74 = loadTypesAdder("74"); } return ta74; } else { if (ta72 == null) { ta72 = loadTypesAdder("72"); } return ta72; } } else { if (ta80 == null) { ta80 = loadTypesAdder("80"); } return ta80; } }