public void execSQLUpdate(String s) throws SQLException { BaseStatement stmt = (BaseStatement) createStatement(); if (stmt.executeWithFlags(s, QueryExecutor.QUERY_NO_METADATA | QueryExecutor.QUERY_NO_RESULTS | QueryExecutor.QUERY_SUPPRESS_BEGIN)) throw new PSQLException(GT.tr("A result was returned when none was expected."), PSQLState.TOO_MANY_RESULTS); // Transfer warnings to the connection, since the user never // has a chance to see the statement itself. SQLWarning warnings = stmt.getWarnings(); if (warnings != null) addWarning(warnings); stmt.close(); }
@Override public ResultSet getTableTypes() throws SQLException { String[] types = tableTypeClauses.keySet().toArray(new String[0]); Arrays.sort(types); Field[] f = new Field[1]; List<byte[][]> v = new ArrayList<byte[][]>(); f[0] = new Field("TABLE_TYPE", Oid.VARCHAR); for (String type : types) { byte[][] tuple = new byte[1][]; tuple[0] = connection.encodeString(type); v.add(tuple); } return ((BaseStatement) createMetaDataStatement()).createDriverResultSet(f, v); }
public AbstractJdbc2ResultSet(Query originalQuery, BaseStatement statement, Field[] fields, Vector tuples, ResultCursor cursor, int maxRows, int maxFieldSize, int rsType, int rsConcurrency) throws SQLException { this.originalQuery = originalQuery; this.connection = (BaseConnection) statement.getConnection(); this.statement = statement; this.fields = fields; this.rows = tuples; this.cursor = cursor; this.maxRows = maxRows; this.maxFieldSize = maxFieldSize; this.resultsettype = rsType; this.resultsetconcurrency = rsConcurrency; }
/** * Simple query execution. */ public ResultSet execSQLQuery(String s, int resultSetType, int resultSetConcurrency) throws SQLException { BaseStatement stat = (BaseStatement) createStatement(resultSetType, resultSetConcurrency); boolean hasResultSet = stat.executeWithFlags(s, QueryExecutor.QUERY_SUPPRESS_BEGIN); while (!hasResultSet && stat.getUpdateCount() != -1) hasResultSet = stat.getMoreResults(); if (!hasResultSet) throw new PSQLException(GT.tr("No results were returned by the query."), PSQLState.NO_DATA); // Transfer warnings to the connection, since the user never // has a chance to see the statement itself. SQLWarning warnings = stat.getWarnings(); if (warnings != null) addWarning(warnings); return stat.getResultSet(); }
public synchronized int getPGType(String pgTypeName) throws SQLException { Integer oid = _pgNameToOid.get(pgTypeName); if (oid != null) { return oid; } PreparedStatement oidStatement = getOidStatement(pgTypeName); // Go through BaseStatement to avoid transaction start. if (!((BaseStatement) oidStatement).executeWithFlags(QueryExecutor.QUERY_SUPPRESS_BEGIN)) { throw new PSQLException(GT.tr("No results were returned by the query."), PSQLState.NO_DATA); } oid = Oid.UNSPECIFIED; ResultSet rs = oidStatement.getResultSet(); if (rs.next()) { oid = (int) rs.getLong(1); String internalName = rs.getString(2); _oidToPgName.put(oid, internalName); _pgNameToOid.put(internalName, oid); } _pgNameToOid.put(pgTypeName, oid); rs.close(); return oid; }
@Override public ResultSet execSQLQuery(String s, int resultSetType, int resultSetConcurrency) throws SQLException { BaseStatement stat = (BaseStatement) createStatement(resultSetType, resultSetConcurrency); boolean hasResultSet = stat.executeWithFlags(s, QueryExecutor.QUERY_SUPPRESS_BEGIN); while (!hasResultSet && stat.getUpdateCount() != -1) { hasResultSet = stat.getMoreResults(); } if (!hasResultSet) { throw new PSQLException(GT.tr("No results were returned by the query."), PSQLState.NO_DATA); } // Transfer warnings to the connection, since the user never // has a chance to see the statement itself. SQLWarning warnings = stat.getWarnings(); if (warnings != null) { addWarning(warnings); } return stat.getResultSet(); }
public synchronized int getPGType(String pgTypeName) throws SQLException { Integer oid = (Integer)_pgNameToOid.get(pgTypeName); if (oid != null) return oid.intValue(); if (_getOidStatement == null) { String sql; if (_conn.haveMinimumServerVersion("7.3")) { sql = "SELECT oid FROM pg_catalog.pg_type WHERE typname = ?"; } else { sql = "SELECT oid FROM pg_type WHERE typname = ?"; } _getOidStatement = _conn.prepareStatement(sql); } _getOidStatement.setString(1, pgTypeName); // Go through BaseStatement to avoid transaction start. if (!((BaseStatement)_getOidStatement).executeWithFlags(QueryExecutor.QUERY_SUPPRESS_BEGIN)) throw new PSQLException(GT.tr("No results were returned by the query."), PSQLState.NO_DATA); oid = new Integer(Oid.UNSPECIFIED); ResultSet rs = _getOidStatement.getResultSet(); if (rs.next()) { oid = new Integer((int)rs.getLong(1)); _oidToPgName.put(oid, pgTypeName); } _pgNameToOid.put(pgTypeName, oid); rs.close(); return oid.intValue(); }
/** * Simple query execution. */ public ResultSet execSQLQuery(String s, int resultSetType, int resultSetConcurrency) throws SQLException { BaseStatement stat = (BaseStatement) createStatement(resultSetType, resultSetConcurrency); boolean hasResultSet = stat.executeWithFlags(s, QueryExecutor.QUERY_SUPPRESS_BEGIN); while (!hasResultSet && stat.getUpdateCount() != -1) hasResultSet = stat.getMoreResults(); if (!hasResultSet) throw new PSQLException(GT.tr("No results were returned by the query."), PSQLState.NO_DATA); // Transfer warnings to the connection, since the user never // has a chance to see the statement itself. SQLWarning warnings = stat.getWarnings(); if (warnings != null) addWarning(warnings); return stat.getResultSet(); }
/** * PostgreSQL does not support multiple catalogs from a single connection, so to reduce confusion * we only return the current catalog. {@inheritDoc} */ @Override public ResultSet getCatalogs() throws SQLException { Field[] f = new Field[1]; List<byte[][]> v = new ArrayList<byte[][]>(); f[0] = new Field("TABLE_CAT", Oid.VARCHAR); byte[][] tuple = new byte[1][]; tuple[0] = connection.encodeString(connection.getCatalog()); v.add(tuple); return ((BaseStatement) createMetaDataStatement()).createDriverResultSet(f, v); }
@Override public void execSQLUpdate(String s) throws SQLException { BaseStatement stmt = (BaseStatement) createStatement(); if (stmt.executeWithFlags(s, QueryExecutor.QUERY_NO_METADATA | QueryExecutor.QUERY_NO_RESULTS | QueryExecutor.QUERY_SUPPRESS_BEGIN)) { throw new PSQLException(GT.tr("A result was returned when none was expected."), PSQLState.TOO_MANY_RESULTS); } // Transfer warnings to the connection, since the user never // has a chance to see the statement itself. SQLWarning warnings = stmt.getWarnings(); if (warnings != null) { addWarning(warnings); } stmt.close(); }
if (!((BaseStatement) _getNameStatement).executeWithFlags(QueryExecutor.QUERY_SUPPRESS_BEGIN)) { throw new PSQLException(GT.tr("No results were returned by the query."), PSQLState.NO_DATA);
PgResultSet(Query originalQuery, BaseStatement statement, Field[] fields, List<byte[][]> tuples, ResultCursor cursor, int maxRows, int maxFieldSize, int rsType, int rsConcurrency, int rsHoldability) throws SQLException { // Fail-fast on invalid null inputs if (tuples == null) { throw new NullPointerException("tuples must be non-null"); } if (fields == null) { throw new NullPointerException("fields must be non-null"); } this.originalQuery = originalQuery; this.connection = (BaseConnection) statement.getConnection(); this.statement = statement; this.fields = fields; this.rows = tuples; this.cursor = cursor; this.maxRows = maxRows; this.maxFieldSize = maxFieldSize; this.resultsettype = rsType; this.resultsetconcurrency = rsConcurrency; }
/** * Simple query execution. */ public ResultSet execSQLQuery(String s, int resultSetType, int resultSetConcurrency) throws SQLException { BaseStatement stat = (BaseStatement) createStatement(resultSetType, resultSetConcurrency); boolean hasResultSet = stat.executeWithFlags(s, QueryExecutor.QUERY_SUPPRESS_BEGIN); while (!hasResultSet && stat.getUpdateCount() != -1) hasResultSet = stat.getMoreResults(); if (!hasResultSet) throw new PSQLException(GT.tr("No results were returned by the query."), PSQLState.NO_DATA); // Transfer warnings to the connection, since the user never // has a chance to see the statement itself. SQLWarning warnings = stat.getWarnings(); if (warnings != null) addWarning(warnings); return stat.getResultSet(); }
public java.sql.ResultSet getCatalogs() throws SQLException { Field f[] = new Field[1]; Vector v = new Vector(); f[0] = new Field("TABLE_CAT", Oid.VARCHAR); byte[][] tuple = new byte[1][]; tuple[0] = connection.encodeString(connection.getCatalog()); v.addElement(tuple); return (ResultSet) ((BaseStatement)createMetaDataStatement()).createDriverResultSet(f, v); }
public void execSQLUpdate(String s) throws SQLException { BaseStatement stmt = (BaseStatement) createStatement(); if (stmt.executeWithFlags(s, QueryExecutor.QUERY_NO_METADATA | QueryExecutor.QUERY_NO_RESULTS | QueryExecutor.QUERY_SUPPRESS_BEGIN)) throw new PSQLException(GT.tr("A result was returned when none was expected."), PSQLState.TOO_MANY_RESULTS); // Transfer warnings to the connection, since the user never // has a chance to see the statement itself. SQLWarning warnings = stmt.getWarnings(); if (warnings != null) addWarning(warnings); stmt.close(); }
public synchronized String getPGType(int oid) throws SQLException { if (oid == Oid.UNSPECIFIED) return null; String pgTypeName = (String)_oidToPgName.get(new Integer(oid)); if (pgTypeName != null) return pgTypeName; if (_getNameStatement == null) { String sql; if (_conn.haveMinimumServerVersion("7.3")) { sql = "SELECT typname FROM pg_catalog.pg_type WHERE oid = ?"; } else { sql = "SELECT typname FROM pg_type WHERE oid = ?"; } _getNameStatement = _conn.prepareStatement(sql); } _getNameStatement.setInt(1, oid); // Go through BaseStatement to avoid transaction start. if (!((BaseStatement)_getNameStatement).executeWithFlags(QueryExecutor.QUERY_SUPPRESS_BEGIN)) throw new PSQLException(GT.tr("No results were returned by the query."), PSQLState.NO_DATA); ResultSet rs = _getNameStatement.getResultSet(); if (rs.next()) { pgTypeName = rs.getString(1); _pgNameToOid.put(pgTypeName, new Integer(oid)); _oidToPgName.put(new Integer(oid), pgTypeName); } rs.close(); return pgTypeName; }
public AbstractJdbc2ResultSet(Query originalQuery, BaseStatement statement, Field[] fields, Vector tuples, ResultCursor cursor, int maxRows, int maxFieldSize, int rsType, int rsConcurrency) throws SQLException { this.originalQuery = originalQuery; this.connection = (BaseConnection) statement.getConnection(); this.statement = statement; this.fields = fields; this.rows = tuples; this.cursor = cursor; this.maxRows = maxRows; this.maxFieldSize = maxFieldSize; this.resultsettype = rsType; this.resultsetconcurrency = rsConcurrency; }
public java.sql.ResultSet getTableTypes() throws SQLException { String types[] = new String[tableTypeClauses.size()]; Enumeration e = tableTypeClauses.keys(); int i = 0; while (e.hasMoreElements()) { types[i++] = (String)e.nextElement(); } sortStringArray(types); Field f[] = new Field[1]; Vector v = new Vector(); f[0] = new Field("TABLE_TYPE", Oid.VARCHAR); for (i = 0; i < types.length; i++) { byte[][] tuple = new byte[1][]; tuple[0] = connection.encodeString(types[i]); v.addElement(tuple); } return (ResultSet) ((BaseStatement)createMetaDataStatement()).createDriverResultSet(f, v); }
public void execSQLUpdate(String s) throws SQLException { BaseStatement stmt = (BaseStatement) createStatement(); if (stmt.executeWithFlags(s, QueryExecutor.QUERY_NO_METADATA | QueryExecutor.QUERY_NO_RESULTS | QueryExecutor.QUERY_SUPPRESS_BEGIN)) throw new PSQLException(GT.tr("A result was returned when none was expected."), PSQLState.TOO_MANY_RESULTS); // Transfer warnings to the connection, since the user never // has a chance to see the statement itself. SQLWarning warnings = stmt.getWarnings(); if (warnings != null) addWarning(warnings); stmt.close(); }
public synchronized int getPGArrayElement (int oid) throws SQLException { if (oid == Oid.UNSPECIFIED) return Oid.UNSPECIFIED; Integer pgType = (Integer) _pgArrayToPgType.get(new Integer(oid)); if (pgType != null) return pgType.intValue(); if (_getArrayElementOidStatement == null) { String sql; if (_conn.haveMinimumServerVersion("7.3")) { sql = "SELECT e.oid, e.typname FROM pg_catalog.pg_type t, pg_catalog.pg_type e WHERE t.oid = ? and t.typelem = e.oid"; } else { sql = "SELECT e.oid, e.typname FROM pg_type t, pg_type e WHERE t.oid = ? and t.typelem = e.oid"; } _getArrayElementOidStatement = _conn.prepareStatement(sql); } _getArrayElementOidStatement.setInt(1, oid); // Go through BaseStatement to avoid transaction start. if (!((BaseStatement) _getArrayElementOidStatement).executeWithFlags(QueryExecutor.QUERY_SUPPRESS_BEGIN)) throw new PSQLException(GT.tr("No results were returned by the query."), PSQLState.NO_DATA); ResultSet rs = _getArrayElementOidStatement.getResultSet(); if (!rs.next()) throw new PSQLException(GT.tr("No results were returned by the query."), PSQLState.NO_DATA); pgType = new Integer((int)rs.getLong(1)); _pgArrayToPgType.put(new Integer(oid), pgType); _pgNameToOid.put(rs.getString(2), pgType); _oidToPgName.put(pgType, rs.getString(2)); rs.close(); return pgType.intValue(); }