Serialization using Base 64 and Hex Encoding... Which is Better

I have serialized an object and stored in one of the Database column's. I had 2 options to choose from;
Option 1: Serialization into the database using Base 64 Encoder
public static void write(Object obj, PreparedStatement ps)
                throws SQLException, IOException {
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                ObjectOutputStream oout = new ObjectOutputStream(baos);
                oout.writeObject(obj);
                oout.close();
                byte[] buf = baos.toByteArray();
                s = new sun.misc.BASE64Encoder().encode(buf);
                ps.setString(1, s);
//                ps.setBytes(1, Base64.byteArrayToBase64(baos.toByteArray()));
              ps.setBytes(1, baos.toByteArray());
              ps.setInt(2, ++count);
      public static Object read(ResultSet rs, String column)
               throws SQLException, IOException, ClassNotFoundException {
           byte[] buf = new sun.misc.BASE64Decoder().decodeBuffer(s);
//           byte[] buf = Base64.base64ToByteArray(new String(rs.getBytes(column)));
           if (buf != null) {
           ObjectInputStream objectIn = new ObjectInputStream(
                          new ByteArrayInputStream(buf));
                          Object obj = objectIn.readObject();         //Contains the object
                          PersonDetails p = (PersonDetails)obj;
                          System.out.println(p.getName()+"\t"+p.getAge()+"\t"+p.getSex());
             return null;
Option 2: Serialization into the database using Hex Encoding
static char[]      encodeHex(byte[] data)
          Converts an array of bytes into an array of characters representing the hexidecimal values of each byte in order.
static byte[]      decodeHex(char[] data)
          Converts an array of characters representing hexidecimal values into an array of bytes of those same values.Using the above api functions encode and decode for serialization by writing similar Java Serialization read and write functions as shown above..
I want to know which is recommended out of the 2 encodings chosen based on performance and space used by the field in the database

The one which is best is the one which you determine to be best based on measuring your usage patterns in your environment on hardware as close as possible to what you will be using.
There is also a third option... why are you converting your byte[] into characters? You could use a binary field on the database - e.g. BLOB/BINARY/OBJECT instead of CLOB/MEMO/TEXT whatever

Similar Messages

  • Saving image in windows 8.1 using stream and bitmap encoder id

    Hi
    var renderTargetBitmap = new RenderTargetBitmap();
    await renderTargetBitmap.Render(myElementTree);
    var pixels = await renderTargetBitmap.GetPixelsAsync();
    var picker = new FileSavePicker();
    // Picker setup
    var file = await picker.PickSaveFileAsync();
    // File validation
    using (var stream = await file.OpenAsync(FileAccessMode.ReadWrite))
    var encoder = await
    BitmapEncoder.CreateAsync(BitmapEncoder.BmpEncoderId, stream);
    encoder.SetPixelData(BitmapPixelFormat.Rgba8, 100, 0, 96, 96,
    await renderTargetBitmap.GetPixelsAsync());
    await encoder.FlushAsync();
    I have already used the code snippet. Could you please tell me how to save UIElement tree by having the stream and bitmap encoder id as input?
    Thanks
    Satheesh

    Here you go. Set up the file picker and call our CaptureElementToFile function. In this case it's passing the page to capture the whole screen:
    FileSavePicker picker = new FileSavePicker();
    picker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
    picker.SuggestedFileName = "capture.bmp";
    picker.FileTypeChoices.Add("Bitmap File",new List<string>() { ".bmp" });
    StorageFile file = await picker.PickSaveFileAsync();
    CaptureElementToFile(this, file);
    And here's CaptureElementToFile. The BitmapEncoder needs to know information about the size and shape of the pixel buffer and it needs to have the pixels as an Array. If you want to encode to a different size you can include a BitmapTransform.
    async void CaptureElementToFile(UIElement element, StorageFile file)
    RenderTargetBitmap renderTargetBitmap = new RenderTargetBitmap();
    await renderTargetBitmap.RenderAsync(element);
    IBuffer pixelBuffer = await renderTargetBitmap.GetPixelsAsync();
    DisplayInformation dispInfo = DisplayInformation.GetForCurrentView();
    using (var stream = await file.OpenAsync(FileAccessMode.ReadWrite))
    var encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.BmpEncoderId, stream);
    encoder.SetPixelData(BitmapPixelFormat.Rgba8, BitmapAlphaMode.Straight,
    (uint)renderTargetBitmap.PixelWidth,
    (uint)renderTargetBitmap.PixelHeight,
    dispInfo.LogicalDpi,dispInfo.LogicalDpi,
    pixelBuffer.ToArray());
    await encoder.FlushAsync();
    --Rob

  • Airport Base station (g) and Express (g) - Which is better?

    I have both from an older wireless system in the house. Both were replaced by a new Time Capsule, which is an (n) system, of course. I currently use the older base station for my printer so all computers can use it wirelessly. The Express is at the other end of the house supplying wireless to my entertainment center.
    The Q: would it be better to move the base station to the entertainment center, or would it even make a difference. It seems it wouldn't matter, but I thought I would ask anyway.

    The Q: would it be better to move the base station to the entertainment center, or would it even make a difference. It seems it wouldn't matter, but I thought I would ask anyway.
    Let's review the absolute best way to connect and then work back from there so you can make a decision based on your requirements.
    The "best" connection in terms of performance (speed and network bandwidth) is always a wired ethernet connection. Newer routers and computers will allow Gigabit speeds between devices up to 300+ feet away. In terms of numbers, that's 1000 Mbps.
    The very best 802.11n 5 GHz wireless systems will allow up to 300 Mbps bandwidth. Most "n" wireless systems are operating at 2.4 GHz, which will allow up to 130 Mbps. I think you may already be seeing where this is going.
    Now, the bandwidth (speed capability) on any wireless system falls off in proportion to the distance from the main router to the device receiving the signal. It's not exactly accurate, but safe to say that a device at 50 feet from the main router is only going to get about half of the signal that a device at 25 feet will get.
    So, with wireless, the rules are always the same. The closer a device is to the broadcast source, the better the performance. Any obstructions like walls or ceiling that absorb the signal come into play as well.
    I think you have your answer.

  • Instead of using *mval and *newcol function which functions we can use

    Hi,
        I am new to BPC Instead of of using *mval function which function we can use and same for *newcol which function we can use in transformation file ?
    thanks in advance

    please post in a BO forum

  • Using headphones and X-Fi: Which setting to choose in games, Surround or Headphon

    I have X-Fi Platinum. In the Audio Console/Console Launcher, I can choose between <i>Headphones</i>, <i>5. Speakers</i> and some other setups, though these two are the only ones apliccable to me. When I connect my headphones, the settings are automatically adjusted to <i>Headphones</i>.
    What I'm wondering about is what to choose in the games I play. Should I choose headphone settings there (or "Stereo", if that's the only stereo choice)? As far as I've gathered, the X-Fi can (to some extent) give 3D-sound in headphones by using CMSS-3D (if I've understood correctly), and I expect that for this to work, a 5.-source must be present (which it isn't if the settings in the game are set to Stereo or Headphones or whatever).
    So, what do I choose in the games? Surround/5. or Stereo/Headphones?
    I've also read at the X-Fi site that games with OpenAL (at least Prey) send the sounds to the sound card along with all the positional information, in which case the sound card does everything depending on the speaker setup in the drivers:
    <i>Because audio is not fixed into a speaker configuration until the final playback stage, Prey audio played through the OpenAL API can be virtualized to surround sound in a far more meaningful way. The audio reaching the card from the game is deli'vered with all its positional information intact thereby allowing the headphone or stereo speaker virtualization algorithms to produce highly convincing surround sound over stereo playback equipment.</i>
    This would also explain why Prey doesn't have a choice between stereo or surround when using OpenAL. How is this done in other OpenAL games? Are there never any speaker setup settings in OpenAL games?

    I think you'll find that PC games pretty much use either DirectSound3D or OpenAL in cases like these and they leave handling the speaker configuration to them. When I've looked into a small number of examples where the game had speaker-configuration settings, all it seemed to do was set the Windows speaker configuration, and had nothing to do with audio handling by the game itself.
    In such cases, what you really want to be able to do is to set your speaker settings up before you launch the game, and just have the game use them as is. You don't want the game changing that, and having such settings within the game just seems an opportunity for the game's programming to aggressi'vely step on your settings. You don't want to start a game with Headphones set, then suspend the game to look as your speaker settings, and find you're set to 2 speakers!
    The SBX-Fi pays attention to the speaker-configuration settings in CL's controls. I think there's an option to synchronize with the Windows speaker-configuration controls (there has been for prior cards at least), and this situation seems a good reason to not enable the synchronization.
    DirectSound on Vista has issues for CL cards because Microsoft removed the hooks which allowed CL to provide hardware acceleration. OpenAL doesn't have this problem, and CL's ALchemy provides a bridge to translate a game's DirectSound calls to OpenAL equivalents.
    You should choose Headphones, and hope you don't have to fiddle with the game's settings.
    -Dave
    ?[email protected]

  • Is it OK for someone to factory reset my iPhone w/o using iTunes and Passcode? Which is what my daughter just did a few days ago.

    My daughter, who she does not know my passcode, factory reset my iPhone w/o using iTunes a few days ago and caused losing my pictures taken during our family trip. Should it be incapable of someone who does not know the passcode of my iPhone to factory reset my iPhone? Or is it a kind of error that Apple is not aware of?

    It is not an error. It is the standard way of regaining access if you have forgotten the passcode.
    iOS: Forgot passcode or device disabled

  • Can someone tell me what's the different between Inspire T3030 and T3100? Which is better?

    Hi, I am considering to buy T3030 and T3100, which one is better if they are at the same price?
    Are they better than x230 by logitech?
    Thanks
    Message Edited by ahtze on 04-14-2007 08:08 PM

    is there any advantage for the purchased one ??
    Other than the fact that it's the ethical thing to do, that using any copy for which you have not obtained a legal license is a criminal copyright violation in almost very country in the world, and that legally purchasing your copy is the only way in which you would get any support from Apple? I would consider those all "advantages", myself.
    Regards.

  • Photoshop CS6 and CC versions - which is better ?

    I use Photoshop CS6 for all my work but some of the features of the CC version are missing (such as the new Perspective warp).  If I install CC can I still use my CS6 files and do these products run parallel or integrated ?  i.e. will I have 2 photoshop programs stored on my hard-drive or one with all of the features of both ?  Thanks for helping  DA

    Think of CC as CS7. It isthe next full upgrade. They just decided to rename it CC as it intragrates into the cloud features like syncing presets for example.
    Therefore all CS6 files will work in CC. You can keep both on your system if you like, why not I do. In fact I have CS5, CS6 and CC at the moment.
    If you choose to, you can uninstall CS6 and keep just CC. Just keep in mind what you save will be for CC and can be loaded into CS6 if you have maximum compatability turned on, otherwise it may not work. (Never tried it)
    If you purchased any plugins or filters, you may need to reinstall them for CC to use them. People have run into issues copy/pasting the files between versions.
    To use any of the new features of photoshop, you need to install CC. CS6 will only get bug corrections. The exception to this is camera raw, the latest version is designed for both CS6 and CC.

  • Pages and .doc files - which is better?

    Hello one and all
    I am looking at converting my .doc files to pages files but I am unsure. I was wondering if it's worth converting my .doc (some .docx) files or just leave them as they are.
    Thanks for your help

    Word Format as they can be sent in either Word or Pages Format…
    …or:

  • Which is better,the Apple TimeCapsule or the WD MyCloud for backing up pixs and datas?

    I am not too sure which is better for backing up my pixs that i have saved and dont want to lose them,am thinking which would be best for me to purchase?the apple timecapsule or the wd mycloud,i heard great things about both but not sure from someone who got experience,so could u help me out and tell me which is better and why?
    thanks in advance...

    Backup is backup. Doesn't matter how you do it, but that you do it.
    Given the choice you posited I would choose the Time Capsule if you want to use Time Machine. If you wish to use third-party backup software then you can only use the WD. It comes with its own proprietary backup software. Or you can go another direction and avoid cloud/network backup which is very slow.
    Basic Backup
    For some people Time Machine will be more than adequate. Time Machine is part of OS X. There are two components:
    1. A Time Machine preferences panel as part of System Preferences;
    2. A Time Machine application located in the Applications folder. It is
         used to manage backups and to restore backups. Time Machine
         requires a backup drive that is at least twice the capacity of the
         drive being backed up.
    3. Time Machine requires a backup drive that is at least double the
         capacity of the drive(s) it backs up.
    Alternatively, get an external drive at least equal in size to the internal hard drive and make (and maintain) a bootable clone/backup. You can make a bootable clone using the Restore option of Disk Utility. You can also make and maintain clones with good backup software. My personal recommendations are (order is not significant):
      1. Carbon Copy Cloner
      2. Get Backup
      3. Deja Vu
      4. SuperDuper!
      5. Synk Pro
      6. Tri-Backup
    Visit The XLab FAQs and read the FAQ on backup and restore.  Also read How to Back Up and Restore Your Files. For help with using Time Machine visit Pondini's Time Machine FAQ for help with all things Time Machine.
    Although you can buy a complete external drive system, you can also put one together if you are so inclined.  It's relatively easy and only requires a Phillips head screwdriver (typically.)  You can purchase hard drives separately.  This gives you an opportunity to shop for the best prices on a hard drive of your choice.  Reliable brands include Seagate, Hitachi, Western Digital, Toshiba, and Fujitsu.  You can find reviews and benchmarks on many drives at Storage Review.
    Enclosures for FireWire and USB are readily available.  You can find only FireWire enclosures, only USB enclosures, and enclosures that feature multiple ports.  I would stress getting enclosures that use the Oxford chipsets especially for Firewire drives (911, 921, 922, for example.)  You can find enclosures at places such as;
      1. Cool Drives
      2. OWC
      3. WiebeTech
      4. Firewire Direct
      5. California Drives
      6. NewEgg
    All you need do is remove a case cover, mount the hard drive in the enclosure and connect the cables, then re-attach the case cover.  Usually the only tool required is a small or medium Phillips screwdriver.

  • Incremental and Full backups using WBADMIN and Task Scheduler in Server 2008 R2

    I'd like to create an automated rotating schedule of backups using wbadmin and task scheduler, which would backup Bare Metal Recovery; System State; Drive C: and D: to a Network Share in a pattern like this:
    Monday - Incremental, overwrite last Monday's
    Tuesday - Incremental, overwrite last Tuesday's
    Wednesday - Incremental, overwrite last Wednesday's
    Thursday - Incremental, overwrite last Thursday's
    Friday - Incremental overwrite last Friday's
    Saturday - Full, overwrite last Saturday's
    I need to use the wbadmin commands within the Task Scheduler and do not know any of the required Syntax to make sure everything goes smoothly, I do not want to do this through the CMD.

    I know each backup for the previous corresponding day will be replaced, how do you figure I wont be able to do incremental backups...
    Because incremental backup is based on Volume Shadow Copy (VSS) feature and due to Windows Server 2008 R2 limitations (this limitation is resolved in Windows 8) only one version of backed up data can be stored in a shared folder. So the
    result is that every time you back up some data on a shared folder, you actually creating a full backup of them.
    is it not supported through task scheduler?
    The Task Scheduler is only a feature that does the tasks that you have defined for it. Actually it runs the
    wbadmin command that runs on an operating system with the mentioned limitation.
    I know you can do Incremental backups through Windows Server Backup, but my limitation using that is I cant setup multiple backups.
    Yes, you are right. Windows Server Backup feature in Windows Server 2008/2008 R2 has not this functionality (although
    ntbackup in Windows XP and Windows Server 2003 had this functionality). So, the only workaround to this limitation is through using Task Scheduler feature with wbadmin command. For more information see the following article:
    http://blogs.technet.com/b/filecab/archive/2009/04/13/customizing-windows-server-backup-schedule.aspx
    So are you saying that even though I want each backup to go to a different place on the Shared Folder that it will replace the previous backup anyways?
    No and because of this I said in my previous post that with some modifications and additions you can do the scenario. For example, you back up to a shared folder with the name of Shared1 on Mondays. You also have been configured the backup feature to back
    up data on another shared folder, named Shared2, on Wednesday. When you repeat the backup operation in Shared1, only the backed up data that resides on it will be affected, and the data on Shared2 remains intact.
    Please feel free to let us know if you have any question or concern.
    Please VOTE as HELPFUL if the post helps you and remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading
    the thread.
    Hi R.Alikhani
    Then do you know if wbadmin supports incremental backup in Windows 8? As you said the VSS issue is fixed in Win8. However, the wbadmin has less options then in windows server. I tried a bit but it seems it only supports full backup? ps, I use a network share
    - will the incremental backup works if I define a ISCCI then? My remote backup PC is also running Win8.

  • Which is better to sync, wifi or iCloud?

    I heard that you shouldn't sync with itunes and icloud.  Which is better, and how do you set that up?

    Where did you hear you shouldn't use these?
    You're comparing apples and oranges. Wifi sync is a way to wirelessly sync with iTunes on your Mac or PC. This includes content that you've purchased, content that you've ripped from your own CD collection, as well as things like playlists, song ratings, etc. This is just to replace plugging in your USB cable as you've always had to do in the past.
    iCloud is a way to store some of your content on Apple's servers and retrieve it on any iCloud enabled device. Note this includes only content you've purchased (music, movies, tv shows) or content you've created using iCloud-enabled apps like Pages, Numbers, or Keynote. iCloud doesn't let you sync "metadata" such as playlists, song ratings, etc. if you add a song to a playlist on your iPhone, it won't show up on that same playlist on your iPad, Mac, or PC because you use iCloud. It only gets moved on those other devices after you sync. iCloud also provides a means to keep calendars, contacts, notes, and reminders the same across multiple devices. Finally, iCloud let's you backup your device to the cloud instead of to your Mac or PC, which is handy feature as you don't have to worry about losing your backup should your Mac or PC fail.
    You can choose to use iCloud and not wifi sync, or use wifi sync and not iCloud, or use both or use neither. They are independent of one another and provide different functions.
    Personally, I use both. I wirelessly sync so my iDevices are up to date, and I take advantage of iCloud for my backups, calendar, contacts, etc.

  • Which is better graphic for iMac 2007 or MacBook Air 2012

    iMac use ATI Radeon HD 2600 Pro 256 MB and MacBook Air use intel graphic 5000m so which is better?

    Without knowing how you intend to use the computer it's impossible to say, also you are comparing apples and oranges.

  • Which is better for gaming intel hd graphics 3000 or nvidia geforce

    i want to sue steam and i sonder which is better for gaming :Intel HD Graphics 3000 384 MB graphics or nvidia geforce . If you know a better graphics card please let me know thanx.

    sorry i had lots of typos

  • Songs with the same title, which is better?

    Song titles aren't always unique to one song, there can be many different ones with the same title. This thread is for those kinds of songs. Post them and tell us which is better to you, and why do you think that is.
    For example, I think this song:
    Is better than this one:
    Because I'm a bit more partial to Pulp and Britpop. But I still think Tom Jones' song is great nonetheless.
    Go ahead and give us your opinion!

    For me, I chose two songs called "Living Well; one by American shoegazers Velocity Girl, the other by Texas slowcore group Bedhead. Although I like both, I prefer the Pavement-ish melancholy of the Bedhead song to the sugary rush of the Velocity Girl song. spotify:track:5BrtSevKCfYWuZ6WnBv9Vcspotify:track:1Fu9pnUNBbyTUOsA5ZwsMd

Maybe you are looking for

  • Business Partner relationship replication issue.R1781

    Hi Experts, I am currently modifying BP in ERP and in that I am changing Partner function. So when I replace any existing partner for any given partner function and save ( in XD02) a Bdoc travels to CRM. That BDoc is failed to process and in SMW01 I

  • The app that won't go away-

    Christian SpeedDate. That's the app that I installed at one time. I have since decided to take it off my iPhone, but iTunes wants to keep updating it anyway. Fine, doesn't matter to me, I don't plan on reinstalling it to my iPhone anytime soon, but m

  • Delivery unit in material master should appear on item level of delivery

    Dear SD Sales and Delivery experts, i would appreciate your support very much!!! We want to implement the following small functionality: The components concerned are material master, order and delivery item. The material master is maintained in folde

  • ASA SSL Authentication special caracters

    Hi, I have a ASA 5540 configured in WebVPN to authenticate users through an ACS server. The ACS server can use my Active Directory Users Database. a user with those credentials: login : testuser pass : céli20 can login through Remote Access VPN (cla

  • Vision builder 3.5 compatibil​ity

    Hi, I have Vision builder 3.5 that I want to use with Labview 8.6, are they compatible? /Jenny