public Array createArrayOf(String typeName, Object[] elements) throws SQLException { checkClosed(); int oid = getTypeInfo().getPGArrayType(typeName); if (oid == Oid.UNSPECIFIED) throw new PSQLException(GT.tr("Unable to find server array type for provided name {0}.", typeName), PSQLState.INVALID_NAME); StringBuffer sb = new StringBuffer(); appendArray(sb, elements); // This will not work once we have a JDBC 5, // but it'll do for now. return new Jdbc4Array(this, oid, sb.toString()); }
public AbstractJdbc4Connection(String host, int port, String user, String database, Properties info, String url) throws SQLException { super(host, port, user, database, info, url); TypeInfo types = getTypeInfo(); if (haveMinimumServerVersion("8.3")) { types.addCoreType("xml", Oid.XML, java.sql.Types.SQLXML, "java.sql.SQLXML", Oid.XML_ARRAY); } _clientInfo = new Properties(); if (haveMinimumServerVersion("9.0")) { String appName = info.getProperty("ApplicationName"); if (appName == null) { appName = ""; } _clientInfo.put("ApplicationName", appName); } }
public void setClientInfo(String name, String value) throws SQLClientInfoException { if (haveMinimumServerVersion("9.0") && "ApplicationName".equals(name)) { if (value == null) value = ""; try { StringBuffer sql = new StringBuffer("SET application_name = '"); Utils.appendEscapedLiteral(sql, value, getStandardConformingStrings()); sql.append("'"); execSQLUpdate(sql.toString()); } catch (SQLException sqle) { Map<String, ClientInfoStatus> failures = new HashMap<String, ClientInfoStatus>(); failures.put(name, ClientInfoStatus.REASON_UNKNOWN); throw new SQLClientInfoException(GT.tr("Failed to set ClientInfo property: {0}", "ApplicationName"), sqle.getSQLState(), failures, sqle); } _clientInfo.put(name, value); return; } Map<String, ClientInfoStatus> failures = new HashMap<String, ClientInfoStatus>(); failures.put(name, ClientInfoStatus.REASON_UNKNOWN_PROPERTY); throw new SQLClientInfoException(GT.tr("ClientInfo property not supported."), PSQLState.NOT_IMPLEMENTED.getState(), failures); }
public void setClientInfo(Properties properties) throws SQLClientInfoException { if (properties == null || properties.size() == 0) return; Map<String, ClientInfoStatus> failures = new HashMap<String, ClientInfoStatus>(); Iterator<String> i = properties.stringPropertyNames().iterator(); while (i.hasNext()) { String name = i.next(); if (haveMinimumServerVersion("9.0") && "ApplicationName".equals(name)) { String value = properties.getProperty(name); setClientInfo(name, value); } else { failures.put(i.next(), ClientInfoStatus.REASON_UNKNOWN_PROPERTY); } } if (!failures.isEmpty()) throw new SQLClientInfoException(GT.tr("ClientInfo property not supported."), PSQLState.NOT_IMPLEMENTED.getState(), failures); }
public Properties getClientInfo() throws SQLException { checkClosed(); return _clientInfo; }
public Array createArrayOf(String typeName, Object[] elements) throws SQLException { int oid = getTypeInfo().getPGArrayType(typeName); if (oid == Oid.UNSPECIFIED) throw new PSQLException(GT.tr("Unable to find server array type for provided name {0}.", typeName), PSQLState.INVALID_NAME); StringBuffer sb = new StringBuffer(); appendArray(sb, elements); // This will not work once we have a JDBC 5, // but it'll do for now. return new Jdbc4Array(this, oid, sb.toString()); }
private static void appendArray(StringBuffer sb, Object elements) { sb.append('{'); int nElements = java.lang.reflect.Array.getLength(elements); for (int i=0; i<nElements; i++) { if (i > 0) { sb.append(','); } Object o = java.lang.reflect.Array.get(elements, i); if (o == null) { sb.append("NULL"); } else if (o.getClass().isArray()) { appendArray(sb, o); } else { String s = o.toString(); AbstractJdbc2Array.escapeArrayElement(sb, s); } } sb.append('}'); }
public String getClientInfo(String name) throws SQLException { checkClosed(); return _clientInfo.getProperty(name); }
public void setClientInfo(Properties properties) throws SQLClientInfoException { if (properties == null || properties.size() == 0) return; Map<String, ClientInfoStatus> failures = new HashMap<String, ClientInfoStatus>(); Iterator<String> i = properties.stringPropertyNames().iterator(); while (i.hasNext()) { String name = i.next(); if (haveMinimumServerVersion("9.0") && "ApplicationName".equals(name)) { String value = properties.getProperty(name); setClientInfo(name, value); } else { failures.put(i.next(), ClientInfoStatus.REASON_UNKNOWN_PROPERTY); } } if (!failures.isEmpty()) throw new SQLClientInfoException(GT.tr("ClientInfo property not supported."), PSQLState.NOT_IMPLEMENTED.getState(), failures); }
private static void appendArray(StringBuffer sb, Object elements) { sb.append('{'); int nElements = java.lang.reflect.Array.getLength(elements); for (int i=0; i<nElements; i++) { if (i > 0) { sb.append(','); } Object o = java.lang.reflect.Array.get(elements, i); if (o == null) { sb.append("NULL"); } else if (o.getClass().isArray()) { appendArray(sb, o); } else { String s = o.toString(); AbstractJdbc2Array.escapeArrayElement(sb, s); } } sb.append('}'); }
public Array createArrayOf(String typeName, Object[] elements) throws SQLException { checkClosed(); int oid = getTypeInfo().getPGArrayType(typeName); if (oid == Oid.UNSPECIFIED) throw new PSQLException(GT.tr("Unable to find server array type for provided name {0}.", typeName), PSQLState.INVALID_NAME); StringBuffer sb = new StringBuffer(); appendArray(sb, elements); // This will not work once we have a JDBC 5, // but it'll do for now. return new Jdbc4Array(this, oid, sb.toString()); }
public AbstractJdbc4Connection(String host, int port, String user, String database, Properties info, String url) throws SQLException { super(host, port, user, database, info, url); TypeInfo types = getTypeInfo(); if (haveMinimumServerVersion("8.3")) { types.addCoreType("xml", Oid.XML, java.sql.Types.SQLXML, "java.sql.SQLXML", Oid.XML_ARRAY); } }
public void setClientInfo(String name, String value) throws SQLClientInfoException { if (haveMinimumServerVersion("9.0") && "ApplicationName".equals(name)) { if (value == null) value = ""; try { StringBuffer sql = new StringBuffer("SET application_name = '"); Utils.appendEscapedLiteral(sql, value, getStandardConformingStrings()); sql.append("'"); execSQLUpdate(sql.toString()); } catch (SQLException sqle) { Map<String, ClientInfoStatus> failures = new HashMap<String, ClientInfoStatus>(); failures.put(name, ClientInfoStatus.REASON_UNKNOWN); throw new SQLClientInfoException(GT.tr("Failed to set ClientInfo property: {0}", "ApplicationName"), sqle.getSQLState(), failures, sqle); } _clientInfo.put(name, value); return; } Map<String, ClientInfoStatus> failures = new HashMap<String, ClientInfoStatus>(); failures.put(name, ClientInfoStatus.REASON_UNKNOWN_PROPERTY); throw new SQLClientInfoException(GT.tr("ClientInfo property not supported."), PSQLState.NOT_IMPLEMENTED.getState(), failures); }
public Blob createBlob() throws SQLException { checkClosed(); throw org.postgresql.Driver.notImplemented(this.getClass(), "createBlob()"); }
private static void appendArray(StringBuffer sb, Object elements) { sb.append('{'); int nElements = java.lang.reflect.Array.getLength(elements); for (int i=0; i<nElements; i++) { if (i > 0) { sb.append(','); } Object o = java.lang.reflect.Array.get(elements, i); if (o == null) { sb.append("NULL"); } else if (o.getClass().isArray()) { appendArray(sb, o); } else { String s = o.toString(); AbstractJdbc2Array.escapeArrayElement(sb, s); } } sb.append('}'); }
public AbstractJdbc4Connection(String host, int port, String user, String database, Properties info, String url) throws SQLException { super(host, port, user, database, info, url); TypeInfo types = getTypeInfo(); if (haveMinimumServerVersion("8.3")) { types.addCoreType("xml", Oid.XML, java.sql.Types.SQLXML, "java.sql.SQLXML", Oid.XML_ARRAY); } _clientInfo = new Properties(); if (haveMinimumServerVersion("9.0")) { String appName = info.getProperty("ApplicationName"); if (appName == null) { appName = ""; } _clientInfo.put("ApplicationName", appName); } }
public boolean isValid(int timeout) throws SQLException { checkClosed(); throw org.postgresql.Driver.notImplemented(this.getClass(), "isValid(int)"); }
public SQLXML createSQLXML() throws SQLException { checkClosed(); return new Jdbc4SQLXML(this); }
public <T> T unwrap(Class<T> iface) throws SQLException { checkClosed(); throw org.postgresql.Driver.notImplemented(this.getClass(), "unwrap(Class<T>)"); }
public boolean isWrapperFor(Class<?> iface) throws SQLException { checkClosed(); throw org.postgresql.Driver.notImplemented(this.getClass(), "isWrapperFor(Class<?>)"); }