Package oracle.sql

Examples of oracle.sql.CLOB


      int i = 0;
      if (rs.next() && i < parameters.length) {
        Writer writer = null;
        try {
          String param = parameters[i++].toString();
          CLOB clob = (CLOB)rs.getClob(i);
          writer = clob.getCharacterOutputStream();
          writer.write(param.toCharArray(), 0, param.length());
        } finally {
          try {
            if (writer != null) {
              writer.close();
View Full Code Here


      conn = ((AnyConnection)aconn).getConnection();
      stmt = conn.createStatement();
      rs   = stmt.executeQuery(query);

      if (rs.next()) {
        CLOB clob = (CLOB)rs.getClob(1);
        if (clob == null) {
          return Any.NULL;
        }
        reader = clob.getCharacterStream();
        int length = (int)clob.length();
        //System.err.println("-OracleModule.getClob() length: "+length);
        char[] buffer = new char[length];
        int offset = 0;
        while(offset < length) {
          int read = reader.read(buffer, offset, length - offset);
View Full Code Here

        long totalBytesWritten = 0;
        int bytesRead = 0;
        String theQuery = null;
        FileReader in = null;
        Writer out = null;
        CLOB clob = null;

        try {
            logger.debug9("calling " + SOSClassUtil.getMethodName());
            if (connection == null)
                    throw new Exception(
                            SOSClassUtil.getMethodName()
                                    + ": sorry, there is no successful connection established."
                                    + " may be the connect method was not called");

            if (SOSString.isEmpty(tableName))
                    throw new NullPointerException("tableName is null.");
            if (SOSString.isEmpty(columnName))
                    throw new NullPointerException("columnName is null.");
            if (!file.exists()) throw new Exception("file doesn't exist.");

            query = new StringBuffer("UPDATE ");

            if (tableNameUpperCase)
                query.append(tableName.toUpperCase());
            else
                query.append(tableName);

            if (fieldNameUpperCase) {
                query.append(" SET \"");
                query.append(columnName.toUpperCase());
                query.append("\" = empty_clob() ");
            } else {
                query.append(" SET ");
                query.append(columnName);
                query.append(" = empty_clob() ");
            }

            if (!SOSString.isEmpty(condition))
                condition = " WHERE " + condition;
            else
                condition = "";

            query.append(condition);

            theQuery = this.normalizeStatement(query.toString(), replacement);
            logger.debug6(SOSClassUtil.getMethodName() + ": " + theQuery);

            stmt = connection.createStatement();
            stmt.executeUpdate(theQuery);
            try {
                stmt.close();
                stmt = null;
            } catch (Exception e) {
                throw new Exception("an error occurred closing the statement: "
                        + e);
            }
            stmt = connection.createStatement();
            if (fieldNameUpperCase) {
                query = new StringBuffer("SELECT \"");
                query.append(columnName.toUpperCase());
                query.append("\" FROM ");
            } else {
                query = new StringBuffer("SELECT ");
                query.append(columnName);
                query.append(" FROM ");
            }

            if (tableNameUpperCase)
                query.append(tableName.toUpperCase());
            else
                query.append(tableName);

            query.append(" ");
            query.append(condition);
            query.append(" for update nowait");
            theQuery = this.normalizeStatement(query.toString(), replacement);
            logger.debug6(SOSClassUtil.getMethodName() + ": " + theQuery);
            rs = stmt.executeQuery(theQuery);
            if (rs.next()) clob = (CLOB) rs.getClob(1);

            in = new FileReader(file);
            char[] buffer = new char[clob.getBufferSize()];
            out = clob.getCharacterOutputStream();

            while ((bytesRead = in.read(buffer)) != -1) {
                out.write(buffer, 0, bytesRead);
                totalBytesWritten += bytesRead;
            }
View Full Code Here

        int bytesRead = 0;
        int bufferSize = 0;
        String theQuery = null;
        Writer out = null;
        StringReader in = null;
        CLOB clob = null;

        try {
            logger.debug9("calling " + SOSClassUtil.getMethodName());
            if (connection == null)
                    throw new Exception(
                            "sorry, there is no successful connection established."
                                    + " may be the connect method is not called");

            if (SOSString.isEmpty(tableName))
                    throw new NullPointerException("tableName is null.");
            if (SOSString.isEmpty(columnName))
                    throw new NullPointerException("columnName is null.");
            if (SOSString.isEmpty(data))
                    throw new Exception("data has null value.");

            query = new StringBuffer("UPDATE ");
            if (tableNameUpperCase)
                query.append(tableName.toUpperCase());
            else
                query.append(tableName);

            if (fieldNameUpperCase) {
                query.append(" SET \"");
                query.append(columnName.toUpperCase());
                query.append("\" = empty_clob() ");
            } else {
                query.append(" SET ");
                query.append(columnName);
                query.append(" = empty_clob() ");
            }

            if (!SOSString.isEmpty(condition))
                condition = " WHERE " + condition;
            else
                condition = "";

            query.append(condition);

            theQuery = this.normalizeStatement(query.toString(), replacement);
            logger.debug6(SOSClassUtil.getMethodName() + ": " + theQuery);

            stmt = connection.createStatement();
            stmt.executeUpdate(theQuery);
            try {
                stmt.close();
                stmt = null;
            } catch (Exception e) {
                throw new Exception(" an error occurred closing the statement: "
                        + e);
            }
            stmt = connection.createStatement();
            if (fieldNameUpperCase) {
                query = new StringBuffer("SELECT \"");
                query.append(columnName.toUpperCase());
                query.append("\" FROM ");
            } else {
                query = new StringBuffer("SELECT ");
                query.append(columnName);
                query.append(" FROM ");
            }

            if (tableNameUpperCase)
                query.append(tableName.toUpperCase());
            else
                query.append(tableName);

            query.append(" ");
            query.append(condition);
            query.append(" for update nowait");
            theQuery = this.normalizeStatement(query.toString(), replacement);
            logger.debug6(SOSClassUtil.getMethodName() + ": " + theQuery);
            rs = stmt.executeQuery(theQuery);
            if (rs.next()) clob = (CLOB) rs.getClob(1);
            bufferSize = clob.getBufferSize();
            char[] buffer = new char[bufferSize];
            out = clob.getCharacterOutputStream();
            in = new StringReader(data);
            while ((bytesRead = in.read(buffer, 0, bufferSize)) != -1) {
                out.write(buffer, 0, bytesRead);
                totalBytesWritten += bytesRead;
            }
View Full Code Here

                            int bufSize = 1024;

                            index++;

                            if (type.equals("ascii")) {
                                CLOB ascii = set.getCLOB(index);

                                if (attr instanceof File) {
                                    File asciiFile = (File) attr;
                                    stream = new BufferedInputStream(new FileInputStream(asciiFile));
                                } else {
                                    String asciiText = (String) attr;
                                    stream = new BufferedInputStream(new ByteArrayInputStream(asciiText.getBytes()));
                                }

                                output = new BufferedOutputStream(ascii.getAsciiOutputStream());
                                bufSize = ascii.getBufferSize();
                            } else {
                                BLOB binary = set.getBLOB(index);
                                File binaryFile = (File) attr;
                                stream = new BufferedInputStream(new FileInputStream(binaryFile));
                                length = (int) binaryFile.length();
View Full Code Here

                            int bufSize = 1024;

                            index++;

                            if (type.equals("ascii")) {
                                CLOB ascii = set.getCLOB(index);

                                if (attr instanceof File) {
                                    File asciiFile = (File) attr;
                                    stream = new BufferedInputStream(new FileInputStream(asciiFile));
                                } else {
                                    String asciiText = (String) attr;
                                    stream = new BufferedInputStream(new ByteArrayInputStream(asciiText.getBytes()));
                                }

                                output = new BufferedOutputStream(ascii.getAsciiOutputStream());
                                bufSize = ascii.getBufferSize();
                            } else {
                                BLOB binary = set.getBLOB(index);
                                File binaryFile = (File) attr;
                                stream = new BufferedInputStream(new FileInputStream(binaryFile));
                                length = (int) binaryFile.length();
View Full Code Here

                            int bufSize = 1024;

                            index++;

                            if (type.equals("ascii")) {
                                CLOB ascii = set.getCLOB(index);

                                if (attr instanceof File) {
                                    File asciiFile = (File) attr;
                                    stream = new BufferedInputStream(new FileInputStream(asciiFile));
                                } else {
                                    String asciiText = (String) attr;
                                    stream = new BufferedInputStream(new ByteArrayInputStream(asciiText.getBytes()));
                                }

                                output = new BufferedOutputStream(ascii.getAsciiOutputStream());
                                bufSize = ascii.getBufferSize();
                            } else {
                                BLOB binary = set.getBLOB(index);
                                File binaryFile = (File) attr;
                                stream = new BufferedInputStream(new FileInputStream(binaryFile));
                                length = (int) binaryFile.length();
View Full Code Here

      row.put(key, ((BigDecimal)value).doubleValue());
      row.put(key, value);
    } else if( value instanceof CLOB) {
     
      try {
        CLOB cValue = (CLOB)value;
        int length = (int) cValue.length();
        String stringValue = new String(cValue.getSubString(1, length) );
        row.put(key, stringValue);
        cValue = null;
      } catch (SQLException e) {
        e.printStackTrace();
      }
View Full Code Here

                            int bufSize = 1024;

                            index++;

                            if (type.equals("ascii")) {
                                CLOB ascii = set.getCLOB(index);

                                if (attr instanceof File) {
                                    File asciiFile = (File) attr;
                                    stream = new BufferedInputStream(new FileInputStream(asciiFile));
                                } else {
                                    String asciiText = (String) attr;
                                    stream = new BufferedInputStream(new ByteArrayInputStream(asciiText.getBytes()));
                                }

                                output = new BufferedOutputStream(ascii.getAsciiOutputStream());
                                bufSize = ascii.getBufferSize();
                            } else {
                                BLOB binary = set.getBLOB(index);
                                File binaryFile = (File) attr;
                                stream = new BufferedInputStream(new FileInputStream(binaryFile));
                                length = (int) binaryFile.length();
View Full Code Here

                            int bufSize = 1024;

                            index++;

                            if (type.equals("ascii")) {
                                CLOB ascii = set.getCLOB(index);

                                if (attr instanceof File) {
                                    File asciiFile = (File) attr;
                                    stream = new BufferedInputStream(new FileInputStream(asciiFile));
                                } else {
                                    String asciiText = (String) attr;
                                    stream = new BufferedInputStream(new ByteArrayInputStream(asciiText.getBytes()));
                                }

                                output = new BufferedOutputStream(ascii.getAsciiOutputStream());
                                bufSize = ascii.getBufferSize();
                            } else {
                                BLOB binary = set.getBLOB(index);
                                File binaryFile = (File) attr;
                                stream = new BufferedInputStream(new FileInputStream(binaryFile));
                                length = (int) binaryFile.length();
View Full Code Here

TOP

Related Classes of oracle.sql.CLOB

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.