Tabnine Logo
CopyIn.endCopy
Code IndexAdd Tabnine to your IDE (free)

How to use
endCopy
method
in
org.postgresql.copy.CopyIn

Best Java code snippets using org.postgresql.copy.CopyIn.endCopy (Showing top 14 results out of 315)

origin: org.postgresql/postgresql

public long endCopy() throws SQLException {
 if (at > 0) {
  op.writeToCopy(copyBuffer, 0, at);
 }
 op.endCopy();
 return getHandledRowCount();
}
origin: postgresql/postgresql

public long endCopy() throws SQLException {
  if(at > 0) {
    op.writeToCopy(copyBuffer, 0, at);
  }
  op.endCopy();
  return getHandledRowCount();
}
origin: org.postgresql/postgresql

 /**
  * Use COPY FROM STDIN for very fast copying from an InputStream into a database table.
  *
  * @param sql COPY FROM STDIN statement
  * @param from a CSV file or such
  * @param bufferSize number of bytes to buffer and push over network to server at once
  * @return number of rows updated for server 8.2 or newer; -1 for older
  * @throws SQLException on database usage issues
  * @throws IOException upon input stream or database connection failure
  */
 public long copyIn(final String sql, InputStream from, int bufferSize)
   throws SQLException, IOException {
  byte[] buf = new byte[bufferSize];
  int len;
  CopyIn cp = copyIn(sql);
  try {
   while ((len = from.read(buf)) >= 0) {
    if (len > 0) {
     cp.writeToCopy(buf, 0, len);
    }
   }
   return cp.endCopy();
  } finally { // see to it that we do not leave the connection locked
   if (cp.isActive()) {
    cp.cancelCopy();
   }
  }
 }
}
origin: postgresql/postgresql

/**
 * Use COPY FROM STDIN for very fast copying from a Reader into a database table.
 * @param sql COPY FROM STDIN statement
 * @param from a CSV file or such
 * @param bufferSize number of characters to buffer and push over network to server at once
 * @return number of rows updated for server 8.2 or newer; -1 for older
 * @throws SQLException on database usage issues
 * @throws IOException upon reader or database connection failure
 */
public long copyIn(final String sql, Reader from, int bufferSize) throws SQLException, IOException {
  char[] cbuf = new char[bufferSize];
  int len;
  CopyIn cp = copyIn(sql);
  try {
    while ( (len = from.read(cbuf)) > 0) {
      byte[] buf = encoding.encode(new String(cbuf, 0, len));
      cp.writeToCopy(buf, 0, buf.length);
    }
    return cp.endCopy();
  } finally { // see to it that we do not leave the connection locked
    if(cp.isActive())
      cp.cancelCopy();
  }
}
origin: postgresql/postgresql

  /**
   * Use COPY FROM STDIN for very fast copying from an InputStream into a database table.
   * @param sql COPY FROM STDIN statement
   * @param from a CSV file or such
   * @param bufferSize number of bytes to buffer and push over network to server at once
   * @return number of rows updated for server 8.2 or newer; -1 for older
   * @throws SQLException on database usage issues
   * @throws IOException upon input stream or database connection failure
   */
  public long copyIn(final String sql, InputStream from, int bufferSize) throws SQLException, IOException {
    byte[] buf = new byte[bufferSize];
    int len;
    CopyIn cp = copyIn(sql);
    try {
      while( (len = from.read(buf)) > 0 ) {
        cp.writeToCopy(buf, 0, len);
      }
      return cp.endCopy();
    } finally { // see to it that we do not leave the connection locked
      if(cp.isActive())
        cp.cancelCopy();
    }
  }
}
origin: org.postgresql/postgresql

/**
 * Use COPY FROM STDIN for very fast copying from a Reader into a database table.
 *
 * @param sql COPY FROM STDIN statement
 * @param from a CSV file or such
 * @param bufferSize number of characters to buffer and push over network to server at once
 * @return number of rows updated for server 8.2 or newer; -1 for older
 * @throws SQLException on database usage issues
 * @throws IOException upon reader or database connection failure
 */
public long copyIn(final String sql, Reader from, int bufferSize)
  throws SQLException, IOException {
 char[] cbuf = new char[bufferSize];
 int len;
 CopyIn cp = copyIn(sql);
 try {
  while ((len = from.read(cbuf)) >= 0) {
   if (len > 0) {
    byte[] buf = encoding.encode(new String(cbuf, 0, len));
    cp.writeToCopy(buf, 0, buf.length);
   }
  }
  return cp.endCopy();
 } finally { // see to it that we do not leave the connection locked
  if (cp.isActive()) {
   cp.cancelCopy();
  }
 }
}
origin: org.ancoron.postgresql/org.postgresql.osgi

public long endCopy() throws SQLException {
  if(at > 0) {
    op.writeToCopy(copyBuffer, 0, at);
  }
  op.endCopy();
  return getHandledRowCount();
}
origin: org.ancoron.postgresql/org.postgresql

public long endCopy() throws SQLException {
  if(at > 0) {
    op.writeToCopy(copyBuffer, 0, at);
  }
  op.endCopy();
  return getHandledRowCount();
}
origin: org.ancoron.postgresql/org.postgresql.osgi

  /**
   * Use COPY FROM STDIN for very fast copying from an InputStream into a database table.
   * @param sql COPY FROM STDIN statement
   * @param from a CSV file or such
   * @param bufferSize number of bytes to buffer and push over network to server at once
   * @return number of rows updated for server 8.2 or newer; -1 for older
   * @throws SQLException on database usage issues
   * @throws IOException upon input stream or database connection failure
   */
  public long copyIn(final String sql, InputStream from, int bufferSize) throws SQLException, IOException {
    byte[] buf = new byte[bufferSize];
    int len;
    CopyIn cp = copyIn(sql);
    try {
      while( (len = from.read(buf)) > 0 ) {
        cp.writeToCopy(buf, 0, len);
      }
      return cp.endCopy();
    } finally { // see to it that we do not leave the connection locked
      if(cp.isActive())
        cp.cancelCopy();
    }
  }
}
origin: org.ancoron.postgresql/org.postgresql

/**
 * Use COPY FROM STDIN for very fast copying from a Reader into a database table.
 * @param sql COPY FROM STDIN statement
 * @param from a CSV file or such
 * @param bufferSize number of characters to buffer and push over network to server at once
 * @return number of rows updated for server 8.2 or newer; -1 for older
 * @throws SQLException on database usage issues
 * @throws IOException upon reader or database connection failure
 */
public long copyIn(final String sql, Reader from, int bufferSize) throws SQLException, IOException {
  char[] cbuf = new char[bufferSize];
  int len;
  CopyIn cp = copyIn(sql);
  try {
    while ( (len = from.read(cbuf)) > 0) {
      byte[] buf = encoding.encode(new String(cbuf, 0, len));
      cp.writeToCopy(buf, 0, buf.length);
    }
    return cp.endCopy();
  } finally { // see to it that we do not leave the connection locked
    if(cp.isActive())
      cp.cancelCopy();
  }
}
origin: org.ancoron.postgresql/org.postgresql.osgi

/**
 * Use COPY FROM STDIN for very fast copying from a Reader into a database table.
 * @param sql COPY FROM STDIN statement
 * @param from a CSV file or such
 * @param bufferSize number of characters to buffer and push over network to server at once
 * @return number of rows updated for server 8.2 or newer; -1 for older
 * @throws SQLException on database usage issues
 * @throws IOException upon reader or database connection failure
 */
public long copyIn(final String sql, Reader from, int bufferSize) throws SQLException, IOException {
  char[] cbuf = new char[bufferSize];
  int len;
  CopyIn cp = copyIn(sql);
  try {
    while ( (len = from.read(cbuf)) > 0) {
      byte[] buf = encoding.encode(new String(cbuf, 0, len));
      cp.writeToCopy(buf, 0, buf.length);
    }
    return cp.endCopy();
  } finally { // see to it that we do not leave the connection locked
    if(cp.isActive())
      cp.cancelCopy();
  }
}
origin: org.ancoron.postgresql/org.postgresql

  /**
   * Use COPY FROM STDIN for very fast copying from an InputStream into a database table.
   * @param sql COPY FROM STDIN statement
   * @param from a CSV file or such
   * @param bufferSize number of bytes to buffer and push over network to server at once
   * @return number of rows updated for server 8.2 or newer; -1 for older
   * @throws SQLException on database usage issues
   * @throws IOException upon input stream or database connection failure
   */
  public long copyIn(final String sql, InputStream from, int bufferSize) throws SQLException, IOException {
    byte[] buf = new byte[bufferSize];
    int len;
    CopyIn cp = copyIn(sql);
    try {
      while( (len = from.read(buf)) > 0 ) {
        cp.writeToCopy(buf, 0, len);
      }
      return cp.endCopy();
    } finally { // see to it that we do not leave the connection locked
      if(cp.isActive())
        cp.cancelCopy();
    }
  }
}
origin: stackoverflow.com

 // your code 
CopyManager copyManager = 
    new CopyManager((BaseConnection) new DataSource().connect());
FileReader from = ...  // different name!
int bufferSize = 65536;

// here starts the copy of the driver's implementation of the copyIn() method.

char[] cbuf = new char[bufferSize];
int len;

// if you store the instance of the CopyIn interface in an instance variable you 
// should be able to call cancelCopy() on it
CopyIn cp = copyManager.copyIn(sql);  

try {
  while ( (len = from.read(cbuf)) > 0) {
    byte[] buf = encoding.encode(new String(cbuf, 0, len));
    cp.writeToCopy(buf, 0, buf.length);
  }
  return cp.endCopy();
} finally { // see to it that we do not leave the connection locked
  if(cp.isActive())
    cp.cancelCopy();
}
origin: org.jumpmind.symmetric/symmetric-postgres

protected void endCopy() {
  if (copyIn != null) {
    try {
      flush();
    } finally {
      try {
        copyIn.endCopy();
      } catch (Exception ex) {
        throw getPlatform().getSqlTemplate().translate(ex);
      } finally {
        copyIn = null;
      }
    }
  }
}
org.postgresql.copyCopyInendCopy

Javadoc

Finishes copy operation successfully.

Popular methods of CopyIn

  • cancelCopy
  • writeToCopy
    Writes specified part of given byte array to an open and writable copy operation.
  • flushCopy
    Force any buffered output to be sent over the network to the backend. In general this is a useless o
  • getHandledRowCount
  • isActive
  • getFieldCount
  • getFieldFormat
  • getFormat

Popular in Java

  • Creating JSON documents from java classes using gson
  • getSharedPreferences (Context)
  • getApplicationContext (Context)
  • startActivity (Activity)
  • Menu (java.awt)
  • Rectangle (java.awt)
    A Rectangle specifies an area in a coordinate space that is enclosed by the Rectangle object's top-
  • Collections (java.util)
    This class consists exclusively of static methods that operate on or return collections. It contains
  • Deque (java.util)
    A linear collection that supports element insertion and removal at both ends. The name deque is shor
  • Set (java.util)
    A Set is a data structure which does not allow duplicate elements.
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now