Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6362185
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:52:35+00:00 2026-05-24T23:52:35+00:00

I am trying to convert serialclob to string. But I am not successful. I

  • 0

I am trying to convert serialclob to string. But I am not successful. I think I am not doing in the correct way. My code is:

char[] buffer;
        int count = 0;
        int length = 0;
        String data = null;
        String[] type;
        StringBuffer sb;
        try{
            SqlRowSet rows = getJdbcTemplate().queryForRowSet("select c.BOUNDING_BOX.GET_WKT() BOUNDING_BOX FROM EXAMPLE c WHERE EXAMPLE_ID = 100",
                    new Object[] {subid});
            SubscriptionModel subscription = new SubscriptionModel();
            System.out.println("bbox");
            SqlRowSetMetaData rsmd = rows.getMetaData();
                type = new String[rsmd.getColumnCount()];
                for(int col=0;col<rsmd.getColumnCount();col++)
                    type[col] = rsmd.getColumnTypeName(col + 1);
                System.out.println("Read rows and only serial clob data type values");
            while(rows.next()){
                System.out.println("test 1 here");
                for(int col=0;col<rsmd.getColumnCount();col++){
                    System.out.println("test 2 here");
                    if("CLOB".equals(type[col]){
                        System.out.println("test 3 here");
                        SerialClob clob = (SerialClob) ((ResultSet) rows).getClob(col + 1);
                        if(clob != null){
                            System.out.println("clob is not null");
                            Reader is = clob.getCharacterStream();

                            sb = new StringBuffer();
                            length = (int) clob.length();

                            if(length>0){
                                buffer = new char[length];
                                count = 0;
                                try{
                                    while((count = is.read(buffer)) != -1)
                                        sb.append(buffer);

                                    data = new String(sb);
                                }catch(Exception e){

                                }
                            }
                            else
                                data = (String) null;
                        }else
                            data = (String) null;
                    }else{
                        data = (String) rows.getObject(col + 1);
                    }
                }
            }
            return subscription;
    }catch(Exception e){
        e.printStackTrace();
    }

But I am getting an error like:

bbox
Read rows and only serial clob data type values
test 1 here
test 2 here
java.lang.ClassCastException: javax.sql.rowset.serial.SerialClob cannot be cast to java.lang.String

Where is my mistake?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T23:52:36+00:00Added an answer on May 24, 2026 at 11:52 pm

    Well this is at least one problem:

    if(type[col] == "CLOB")
    

    That’s comparing string references directly. I suspect this would work better:

    if ("CLOB".equals(type[col]))
    

    That will get you into the right if block. I haven’t looked in detail at the rest of your code – it would be simpler to read and maintain if you could break it up into smaller methods.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When trying to convert date/time from string to DateTime, I'm not getting the correct
Trying to convert this c code into MIPS and run it in SPIM. int
Trying to convert int arrays to string arrays in numpy In [66]: a=array([0,33,4444522]) In
am trying convert string to float,when i am passing single char it is giving
Trying to convert a string to NSURL and this is not happening. barcodeTextLabel.text =
I'm trying to convert some code that worked great in VB, but I can't
I'm trying convert jQuery Data object to JSON string. I tried: $.data(plant).toJSON() JSON.stringify($.data(plant)) but
Trying to convert a bytestring to a hex ascii string display wordtoascii :: Int
I'm trying convert all special chars into HTML safe entities on their way into
Trying to convert a string of binary inputs into a vector of ints. I'd

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.