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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:11:59+00:00 2026-05-26T15:11:59+00:00

In my Sybase 12.0 ASE database, I have at table that contains a column

  • 0

In my Sybase 12.0 ASE database, I have at table that contains a column defined as binary(16) and used to store GUIDS/UUIDs. When i run a select query using a SQL client + ansi SQL for that table, all looks fine..i can see the guid value as i expect it in the resultset (the guid looks something like this “1ae5608d12311de123d001185135a13” in the sql output)

However in code when trying to do this via JDBC(I am using the Sybase “com.sybase.jdbc3.jdbc.SybDriver” driver), when i iterate over the result set and try to read that columnn, it comes back as basically garbage. if i do a ResultSet.getObject(col), where col is the binary column index in my resultset, i see that the type is byte[]. I have tried converting this to string and encoding as Base64, but to no avail.

Any ideas on how to do this?

Thanks

  • 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-26T15:11:59+00:00Added an answer on May 26, 2026 at 3:11 pm

    The byte[] you receive is exactly what it should be: A sequence of 16 bytes or less, according to the column definition.

    What representation of the UID are you trying to create? – They’re not usually represented as Base64 but rather as Hex.

    Trying to convert the byte[] to a String directly is certainly not what you want.
    If you iterate over the array, converting each byte to its (2-digit!) hexadecimal representation (String), and concat those strings to a string of length 32, the result will probably look a lot more like what you need.

    If you want to use java.util.UUID, you should build two long values from the first and the second set of eight bytes, respectively, to be passed to the constructor.

    Edit:

    In java.util.UUID you can find:

    /*
     * Private constructor which uses a byte array to construct the new UUID.
     */
    private UUID(byte[] data) {
        long msb = 0;
        long lsb = 0;
        assert data.length == 16;
        for (int i=0; i<8; i++)
            msb = (msb << 8) | (data[i] & 0xff);
        for (int i=8; i<16; i++)
            lsb = (lsb << 8) | (data[i] & 0xff);
        this.mostSigBits = msb;
        this.leastSigBits = lsb;
    }
    

    I have no idea why it is not public…

    Given your byte[] you can create the two long values needed for the UUID(long,long constructor with exactly this code.

    You will only have to pay attention to the ordering of the bytes in the array you receive from the DB; which one is the least significant byte, which is the most significant byte. (Probably either [0] and [15], or [15] and [0].)

    Once you have an instance of UUID you can use its toString() to get the common representation.

    If you don’t want to use UUID you’d have to convert bytes to hex yourself for output and maybe insert some dashes for readability.

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

Sidebar

Related Questions

I have a couple of triggers in a Sybase ASE database that are fired
I've got a T-SQL stored procedure running on a Sybase ASE database server that
I have a Sybase ASE server that I'm able to connect to with ASE
I have a Sybase table with a column storing char(6) values. I would like
So I have a Sybase stored proc that takes 1 parameter that's a comma
We have very old VB6 applications connecting to a Sybase database. Today they are
I have an ASP.NET app that uses a SQL Server database. I now need
Database: Sybase ASE 15.0.3 Tables: authors(int author_id, varchar(20) author_name) books(int author_id,int number_of_pages) I need
A table in Sybase has a unique varchar(32) column, and a few other columns.
I'm trying to call some legacy stored procedures on a Sybase Database (ASE 15)

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.