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 7642265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:08:43+00:00 2026-05-31T09:08:43+00:00

I have a table. The table has a column ‘Column1’ which is of type

  • 0

I have a table. The table has a column 'Column1' which is of type 'text'.

How can I retrieve the text and store it as a string?

The below is what I attempted. (But it does not work, I get weird characters back, instead of the data within the database)

   public void getConfigurationXML()
   {
       try
       {            
           Class.forName("java.sql.Driver"); 
           Connection conn=(Connection)DriverManager.getConnection(_url,_user,_pwd); 
           Statement st=conn.createStatement(); 

           ArrayList <String[]> result = new ArrayList<String[]>();
           String query ="SELECT Column1 FROM table1";
           ResultSet rs=st.executeQuery(query); 
           int columnCount = rs.getMetaData().getColumnCount();

           while(rs.next())
           { 
               String[] row = new String[columnCount];
               for (int i=0; i <columnCount ; i++)
               {
                   row[i] = rs.getString(i + 1);
               }
               result.add(row);
           } 

           rs.close(); 
           st.close(); 
           conn.close(); 

      } 
      catch(Exception e)
      { 
           Logger lgr = Logger.getLogger(Database.class.getName());
           lgr.log(Level.WARNING, e.getMessage(), e);
      }
   }
  • 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-31T09:08:44+00:00Added an answer on May 31, 2026 at 9:08 am

    If you’re talking about the text datatype that is used for BLOB structures, you can try this:

    java.sql.Blob ablob = rs.getBlob(i + 1);
    row[i] = new String(ablob.getBytes(1L, (int) ablob.length()));
    

    The reason for the weird characters is that the database stores this as raw bytes instead of the characters that you’re expecting.

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

Sidebar

Related Questions

I have a table which has XMLData column as TEXT. How can i read
I have a table which has a column called Direct of type char(1). It's
i have one table (A) which has column caseid and citin , caseid can
I have a table which has a column called lastUpdateTime, datetime type. How to
I have a table which has column of descr which stores string values. Some
i have a table that has following column Type -------- type 1 type 2
I have mysql table that has a column that stores xml as a string.
I have a table User which has an identity column UserID , now what
I have a table which has two varchar(Max) columns Column 1 Column 2 -----------------------
I have a table that has a column which holds the id of a

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.