Package java.sql

Examples of java.sql.Clob


            setTimeouts(stmnt, store.getFetchConfiguration(), true);
            res = stmnt.executeQuery();
            if (!res.next()) {
                throw new InternalException(_loc.get("stream-exception"));
            }
            Clob clob = res.getClob(1);
            if (clob != null) {
                Writer writer = clob.setCharacterStream(1);
                copy(reader, writer);
                writer.close();
                res.updateClob(1, clob);
                res.updateRow();
            }
View Full Code Here


    public String getClobString(ResultSet rs, int column)
        throws SQLException {
        if (useGetStringForClobs)
            return rs.getString(column);

        Clob clob = getClob(rs, column);
        if (clob == null)
            return null;
        if (clob.length() == 0)
            return "";

        // unlikely that we'll have strings over Integer.MAX_VALUE chars
        return clob.getSubString(1, (int) clob.length());
    }
View Full Code Here

                    Blob blob = rs.getBlob(1);
                    return new JDBCInputStream(blob.getBinaryStream(), cnx);
                //break;

                case Types.CLOB :
                    Clob clob = rs.getClob(1);
                    return new JDBCInputStream(clob.getAsciiStream(), cnx);
                //break;

                default :
                    String value = rs.getString(1);
                    stmt.close();
View Full Code Here

        Object value = null;

        switch (type.intValue()) {
        case Types.CLOB:
        case Types.CHAR:
            Clob dbClob = set.getClob(dbcol);
            int length = (int) dbClob.length();
            InputStream asciiStream = new BufferedInputStream(dbClob.getAsciiStream());
            byte[] buffer = new byte[length];
            asciiStream.read(buffer);
            String str = new String(buffer);
            asciiStream.close();
            value = str;
View Full Code Here

        //System.out.println("========================================================================");
        //System.out.println("JDBCTypeConversions: setting type "+typeObject.intValue());
        switch (typeObject.intValue()) {
        case Types.CLOB:
            //System.out.println("CLOB");
            Clob clob = null;
            if (value instanceof Clob) {
                clob = (Clob) value;
            } else if (value instanceof File) {
                File asciiFile = (File) value;
                asciiStream = new BufferedInputStream(new FileInputStream(asciiFile));
View Full Code Here

                case 1:
                    if (java.sql.Types.CLOB == colType) {
                        // Debug.logInfo("For field " + curField.getName() + " of entity " + entity.getEntityName() + " getString is a CLOB, trying getCharacterStream", module);
                        // if the String is empty, try to get a text input stream, this is required for some databases for larger fields, like CLOBs

                        Clob valueClob = rs.getClob(ind);
                        Reader valueReader = null;
                        if (valueClob != null) {
                            valueReader = valueClob.getCharacterStream();
                        }

                        //Reader valueReader = rs.getCharacterStream(ind);
                        if (valueReader != null) {
                            char[] inCharBuffer = new char[CHAR_BUFFER_SIZE];
View Full Code Here

                case 5: {Blob v=rs.getBlob(col);o=v;break;}
                case 6: {boolean v=rs.getBoolean(col);o=new Boolean(v);break;}
                case 7: {byte v=rs.getByte(col);o=new Byte(v);break;}
                case 8: {byte[] v=rs.getBytes(col);o=v;break;}
                case 9: {Reader v=rs.getCharacterStream(col);o=v;break;}
                case 10:{Clob v=rs.getClob(col);o=v;break;}
                case 11:{Date v=rs.getDate(col);o=v; break;}
                case 12:{double v=rs.getDouble(col);o=new Double(v);break;}
                case 13:{float v=rs.getFloat(col);o=new Float(v);break;}
                case 14:{int v=rs.getInt(col);o=new Integer(v);break;}
                case 15:{long v=rs.getLong(col);o=new Long(v);break;}
                case 16:{Ref v=rs.getRef(col);o=v;break;}
                case 17:{short v=rs.getShort(col);o=new Short(v);break;}
                case 18:{String v=rs.getString(col);o=v;break;}
                case 19:{Time v=rs.getTime(col);o=v;break;}
                case 20:{Timestamp v=rs.getTimestamp(col);o=v;break;}
//        case 21:{URL v=rs.getURL(col);o=v;break;}
                default: return null;
            }
            // fixup if it contains classname (remove "random" part after @)
            String v = o.toString();
            if (v.indexOf('@') != -1) { // non standard java object.
                s += "Object'   \t: "+prettyType(o);
            } else {
                // default stringifier...
                s += "'"+v+"'    \t: "+o.getClass().getName();
            }
View Full Code Here

    public String getClobString(ResultSet rs, int column)
        throws SQLException {
        if (_driverBehavior != BEHAVE_ORACLE)
            return super.getClobString(rs, column);

        Clob clob = getClob(rs, column);
        if (clob == null)
            return null;
        if (clob.getClass().getName().equals("oracle.sql.CLOB")) {
            try {
                if (((Boolean) Class.forName("oracle.sql.CLOB").
                    getMethod("isEmptyLob", new Class[0]).
                    invoke(clob, new Object[0])).
                    booleanValue())
                    return null;
            } catch (Exception e) {
                // possibly different version of the driver
            }
        }
        if (clob.length() == 0)
            return null;

        // unlikely that we'll have strings over 4 billion chars
        return clob.getSubString(1, (int) clob.length());
    }
View Full Code Here

     * Test the createClob method implementation in the Connection interface
     * in the Network Client
     */
    void t_createClob_Client() {
        int c;
        Clob clob;
        try {
            Statement s = conn.createStatement();
            s.execute("create table clobtable2(n int,clobcol CLOB)");
            PreparedStatement ps = conn.prepareStatement("insert into clobtable2" +
                    " values(?,?)");
            ps.setInt(1,1000);
            clob = conn.createClob();
            File file = new File("extin/short.txt");
            FileInputStream is = new FileInputStream(file);
            OutputStream os = clob.setAsciiStream(1);
            c = is.read();
            while(c>0) {
                os.write(c);
                c = is.read();
            }
View Full Code Here

     * the setClob method in the PreparedStatement interface
     */
    Clob buildAndInsertClobValue(int n,String filename,Connection conn){
        int c;
        byte [] fromFile = new byte[1024];
        Clob clob=null;
        try {
            clob = conn.createClob();
            java.io.OutputStream os = clob.setAsciiStream(1);
            buildFilePath(filename);
            File f = new File(filepath + sep + filename);
            InputStream is = getInputStream(f);
            c = is.read(fromFile);
            while(c>0) {
View Full Code Here

TOP

Related Classes of java.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.