What is the best way of converting everything in a result set into a string

hello folks
What do you think is the best way of converting everything in a resultset into a string???
At the moment I'm using
rs.getString(i);
everywhere (no matter if the underlying datatype is a date or whatever..) it converts automatically evertything expect NULL into a valid string.
Are there better (simple to use..) ways?

I don't see a big switch construct. How about trying the following:
Call this method from your original method by passing the resultset obtained.
public String[] convert(ResultSet rs) {
     int col = ((ResultSetMetaData) rs.getMetaData()).getColumnCount();
     String[] record = new String[col];
     int i=0;
     while(rs.next()) {
          if(rs.wasNull()) record[i] = new String();
          else record[i] = rs.getString(i);
          i++;
     return record;
iDriZ

Similar Messages

  • What is the best way of converting a Top Level VI into a 'sub vi' - or function ( without duplicating programming)

    Hi,
    General question here about design architecture, which i keep running into, but haven't found a really good solution.  If i write a 'Top Level VI' to do something, what is the best way of converting it into a subVI - which is call-able from other VIs, while still allowing the top level VI to have synchronised feedback/indicator updates.
    I guess the point is that when something is a top level VI you write gui logic about what happens when someone clicks buttons or whatever - which you don't want in the 'sub vi' version.
    I did at one point try having a hidden boolean button that was an input to the subVI which would let the VI know if it was supposed to be doing the front panel stuff - or simply running as a subVI.  This isn't really ideal though - since it would be better to be able to hive off the grizzly useful stuff from the fluffy - front panel updating stuff - having them together makes the VIs rather untidy.  More annoyingly though, if you have the front panel version of it running - say waiting for you to hit 'go', it breaks all the other VIs that use it as a sub vi - since they can't compile when a sub vi is already running.
    Another possibility that i tried was to basically duplicate the vi so that there was a backend part, and a front end part - and when i click 'go' the backend part is called as a sub vi.  The problem with this is that it really limits the interface that the user gets - since none of the controls on the front panel update with the results untill the sub vi is over.  I guess again i could solve this by passing references to some of the controls to update them in the subvi - but this doesn't really seem like the ideal situation if the subvi is called by something else without the same types of controls etc.
    One final idea i had was to essentially paste all the controls in the VI into a global variable file, and make the sub vi update them, and the front panel VI read from them.  This seems to 'work' - although clearly it is a work around rather than a proper solution - since i spend loads of time worrying about how i update cluster variables in the global - reading and writing.
    Does anyone have any guidance on what they do to solve this problem?
    JP

    You could run a subvis in a Subpanel on your top level.  Lets you see the current data while the subvi is running.
    --Using LV8.2, 8.6, 2009, 2012--

  • What's the best way to transfer everything from my 5-year-old iMac to my 1-year-old iMac?

    What's the best way to transfer everything from my 5-year-old iMac to my 1-year-old iMac?
    I'm doing role reversal with these two.  The newer imac is becoming our business computer, the older one will be our personal computer from now on until it gives out.  For the record, I have Carbonite on the business unit.  Should be a no-brainer, right?  (Which is precisely why I'm asking!)
    Thanks for whatever timely and accurate advise you may have.

    Thanks. I stumbled across migration assistant later that afternoon in a google search. Just finished using it today to do the deed. Appreciate your quick response!

  • What's the best way to convert from Gmail to iCloud?

    I currently use Google's free exchange server and sync my contacts and calendar to Google even though I pretty much do all my emailing from either mac, iphone, or ipad. Since it sounds like it's hard to sync to both google and icloud at the same time, would like to make the switch. Is there a FAQ out there? Can I keep my google email and sync just the contacts w/iCloud or is it an all-or-nothing proposition? If so, is that what others do? Any advice / pointers appreciated. Thanks.

    mike needs help wrote:
    What's the best way to convert Raw images to jpegs?
    GraphicConverter:
    http://www.lemkesoft.com/content/188/graphicconverter.html
    Not free either, but the best shareware program ever made for the Mac.

  • What's the best way to convert a current website into a Fluid Grid Laout?

    As the title says....
    What's the best way to convert a current website into a Fluid Grid Laout?

    See "Using Fluid Grid Layouts (video)"
    http://tv.adobe.com/watch/learn-dreamweaver-cs6/using-fluid-grid-layou ts/
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists 
    http://alt-web.com/
    http://twitter.com/altweb
    http://alt-web.blogspot.com/

  • What is the best way to convert mini dv tapes to digital

    I have a Canon ZR800 that I have created several mini dv tapes with.  What is the best way to convert these tapes I made to a digital format?  I have a Macbook to use for the digital format.

    Hello Jhoslter,
    To transfer footage from the ZR800 to your Mac, you will need a firewire (IEEE-1394) cable and a firewire port on your computer.  If your computer is not equipped with a firewire port, we would suggest contacting your computer manufacturer for information regarding which firewire card will work best on your system.
    As it is only possible to transfer video to a computer via firewire connection with the Canon camcorder, any video capturing program that supports firewire connections should be fine to use to transfer video to your computer.  Canon does not manufacture video capturing programs or support a particular brand.   
    Canon does not require firewire drivers for any of our miniDV camcorders.  Our camcorders use the driver for your firewire card to communicate with the computer.
    The appearance of the "DV IN" message in the camcorder's LCD screen indicates that the camcorder has detected your firewire port and is waiting for a signal from the video editing software to begin the transfer of footage.  The remainder of the transfer process is controlled by that software; we would suggest reviewing the instructions for that program for further information.
    Did this answer your question? Please click the Accept as Solution button so that others may find the answer as well.

  • Aloha, I have a CD-Rom from 2001 that i very much want to access but cannot because i no longer have "classic." There are a variety of video and text files. What is the best way to convert? Any help is greatly appreciated. mahalo.

    Aloha, I have a CD-Rom from 2001 that i very much want to access but cannot because i no longer have "classic." There are a variety of video and text files. What is the best way to convert? Any help is greatly appreciated. mahalo.

    Buy a cheap older Mac like an iMac.
     Cheers, Tom

  • What is the best way to import my VHS or Laserdisc Movies into iTunes??

    What is the best way for me to import my vhs movies and laserdisc movies into itunes so I can store them for my family to keep??
    Any suggestions would be great.
    If I get them into itunes I would like to be able to view them on my Apple tv via the computer.
    Can this be done???

    csnolan wrote:
    What is the best way for me to import my vhs movies and laserdisc movies into itunes so I can store them for my family to keep??
    I know this is an old thread, but I've been researching ripping my Laserdiscs to my Mac.  Did you ever get it worked out?  I've been reading here about the Grassvalley ADVC300 to capture and convert analog video to digital.  Still learning about it.  Also, here's a wiki that has a lot of information about ripping laserdiscs:
    http://www.noobelodeon.org/w/How_to_Rip_Laserdisc

  • What is the best way of returning group-by sql results in Toplink?

    I have many-to-many relationship between Employee and Project; so,
    a Employee can have many Projects, and a Project can be owned by many Employees.
    I have three tables in the database:
    Employee(id int, name varchar(32)),
    Project(id int, name varchar(32)), and
    Employee_Project(employee_id int, project_id int), which is the join-table between Employee and Project.
    Now, I want to find out for each employee, how many projects does the employee has.
    The sql query that achieves what I want would look like this:
    select e.id, count(*) as numProjects
    from employee e, employee_project ep
    where e.id = ep.employee_id
    group by e.id
    Just for information, currently I am using a named ReadAllQuery and I write my own sql in
    the Workbench rather than using the ExpressionBuilder.
    Now, my two questions are :
    1. Since there is a "group by e.id" on the query, only e.id can appear in the select clause.
    This prevent me from returning the full Employee pojo using ReadAllQuery.
    I can change the query to a nested query like this
    select e.eid, e.name, emp.cnt as numProjects
    from employee e,
    (select e_inner.id, count(*) as cnt
    from employee e_inner, employee_project ep_inner
    where e_inner.id = ep_inner.employee_id
    group by e_inner.id) emp
    where e.id = emp.id
    but, I don't like the complication of having extra join because of the nested query. Is there a
    better way of doing something like this?
    2. The second question is what is the best way of returning the count(*) or the numProjects.
    What I did right now is that I have a ReadAllQuery that returns a List<Employee>; then for
    each returned Employee pojo, I call a method getNumProjects() to get the count(*) information.
    I had an extra column "numProjects" in the Employee table and in the Employee descriptor, and
    I set this attribute to be "ReadOnly" on the Workbench; (the value for this dummy "numProjects"
    column in the database is always 0). So far this works ok. However, since the numProjects is
    transient, I need to set the query to refreshIdentityMapResult() or otherwise the Employee object
    in the cache could contain stale numProjects information. What I worry is that refreshIdentityMapResult()
    will cause the query to always hit the database and beat the purpose of having a cache. Also, if
    there are multiple concurrent queries to the database, I worry that there will be a race condition
    of updating this transient "numProjects" attribute. What are the better way of returning this kind
    of transient information such as count(*)? Can I have the query to return something like a tuple
    containing the Employee pojo and an int for the count(*), rather than just a Employee pojo with the
    transient int inside the pojo? Please advise.
    I greatly appreciate any help.
    Thanks,
    Frans

    No I don't want to modify the set of attributes after TopLink returns it to me. But I don't
    quite understand why this matters?
    I understand that I can use ReportQuery to return all the Employee's attributes plus the int count(*)
    and then I can iterate through the list of ReportQueryResult to construct the Employee pojo myself.
    I was hesitant of doing this because I think there will be a performance cost of not being able to
    use lazy fetching. For example, in the case of large result sets and the client only needs a few of them,
    if we use the above aproach, we need to iterate through all of them and wastefully create all the Employee
    pojos. On the other hand, if we let Toplink directly return a list of Employee pojo, then we can tell
    Toplink to use ScrollableCursor and to fetch only the first several rows. Please advise.
    Thanks.

  • What is the best way to get audio from a regular cd into logic?

    I need to get some music of a regular music CD into Logic. When doing something like this on a PC I'd get some third party software to rip the CD and convert into audio files that I'd use in the Daw. What is the simplest way on a Mac?

    1. insert CD (der...)
    2. open iTunes and click 'inport cd'
    3. when the tracks are finished inporting drag them into a play list (just to keep things tidy.)
    4. select the tracks you want in logic.
    5. drag the tracks where you want them in logic
    note: when you drag the tracks in logic will create an overview for the tracks, this could take a while depending on the length of the son.
    hope this helps.

  • What is the best way to convert from PowerPoint 2007 to PDF?

    Greetings people,
    In PowerPoint 2007 I know you can convert to a PDF by way of printing, save as or from the Adobe menu. However, these produce different results.
    Is there a reason for this? Can settings be changed to ensure the results are the same regardless of what method is used?
    Is there a rule of thumb on which method is best?
    Thank you, Jean

    A lot depends on what you are after. If you use the printer, you will likely need to use a custom page setting to fill out the page properly and not leave spaces on the sides. I think the standard PPT page is 8.5X10, not 11. PDF Maker (or the Save As Adobe PDF) in PPT sets the size appropriately when I have used it. PDF Maker also adds links and such as appropriate, but the printer does not. Your other option is to use the Save As PDF or XPS which is the MS conversion.
    When I tested, the print did go to an 8.5X11 with a border to fit on the page. The other three techniques created the PDF in the same page size as the PPT. The PDF maker and Acrobat menu methods gave the same results, but the file was about 2X the size of the MS method. I did not check the properties that created this different size, but you would have to look at the different options for the creation and see how they compare. The Adobe approach can be kept small also, but may not have used the same options as the MS approach.
    If there were links, then the print will not embed these links and bookmarks, but the other techniques will. Maybe that helps some.

  • What's the best way to convert between pixels and device-independent units?

    WHAT I HAVE:
    Visual Basic 2010, .NET 4.0, WinForms
    WHAT I NEED:
    I need a way to convert back and forth between device-dependent units (i.e., pixels) and
    device-independent units (i.e., inches, centimeters, points). The VB6Compatibility namespace has TwipsPerPixel methods, but I figure there's got to be a more elegant way (especially since my program didn't start in VB6).
    Robert Gustafson

    "Dots-per-inch" means "pixels-per-inch", right? If I'm right, then
    XPixels = Graphics.DpiX * XInches : YPixels = Graphics.DpiY * YInches
    and, conversely,
    XInches = XPixels / Graphics.DpiX : YInches = YPixels / Graphics.DpiY
    Is that correct?
    (PS. Why not just tell me about the DpiX and DpiY properties, rather than making me click a link?)
    Robert Gustafson

  • What is the best way to move everything from one MacBook Air to another MBA

    I bought a new MacBook Air ( OS 10.6.4, 2.16 GHz, 4GB RAM) = MBA 2. I already have an old MBA (bought late 2009, OS 10.6.0, 1.86 GHz, 2 GB RAM) = MBA 1
    Whenever I had to do a clean install of the MBA 1, I was able to successfully restore all the files and the same architecture of the HD by cloning the MBA 1's HD (onto an external drive) before doing the clean install, then sticking the external drive into the USB port and then using Migration Assistant (selecting other drive in the choices).
    Another method I can use but haven't tried is by connecting the two MBAs together with an ethernet cable (I have ethernet adapters for the two MBAs) and then using Migration Assistant.
    If I use this method, do I have to change anything in Network (in System Preferences) like this person did?
    http://www.zdnet.com/blog/apple/macbook-air-diary-day-3-migration-assistance/125 3
    So the questions I am asking are:-
    1) Which is the better method (faster, more fail-proof, simpler) for migrating?
    External drive plugged into the USB port (with clone of the HD of the older MBA on it)
    OR
    Networking the two computers with an ethernet cable
    2) If I use the networking method, do I have to change anything in Network?
    3) The MBA 2 had 10.6.4 already installed on it. I have used the MBA 2 a little bit, adding browsers and so on, but there is nothing there I want to keep.
    Do I have to do a clean install (sticking the USB flash drive that came with the computer into the MBA 2 and then erasing the disk) before I use the Migration Assistant?
    OR
    Can I just delete all the applications and files I have added since I started using the MBA 2, and then just start up Migration Assistant?
    OR
    Can I just leave the MBA 2 alone and leave it as is and start Migration Assistant? Will the Migration Assistant write over everything that's currently on the computer? (I don't mind if it does.)
    4) Will it be a problem that the MBA 1 has 10.6.0 on it whereas the MBA 2 has 10.6.4 on it? Do I need to update the MBA 1 to 10.6.4 before I do the migration? (I'd rather not if I can avoid it. However, I plan to use 10.6.4 on the new MBA 2).
    Thanks for any replies.

    applecore_eater wrote:
    External drive plugged into the USB port (with clone of the HD of the older MBA on it)
    If the clone is already made, that will be somewhat faster.
    Can I just delete all the applications and files I have added since I started using the MBA 2, and then just start up Migration Assistant?
    Your best bet is to erase the disk, install OSX from the USB stick, then use +Setup Assistant+ when the new Mac restarts. See [Setting up a new Mac from an old one or its backups|http://web.me.com/pondini/AppleTips/Setup.html] (or use the link in *User Tips* at the top of the +Snow Leopard > Installation and Setup+ forum).
    4) Will it be a problem that the MBA 1 has 10.6.0 on it whereas the MBA 2 has 10.6.4 on it?
    No.

  • What are my options for opening EPS files in Elements 13? What is the best way to convert these to another type of vector file?

    I "upgraded" from Photoshop Elements... uh... mad old... to Elements 13 when my work computer got "upgraded" to Win8. Now I can't open EPS files which is how I receive collateral from our ad agency. What other vector files will work, and how can I convert EPS to these? Please be gentle if this is a stupid question - I know enough to be dangerous, but I'm not an expert at design by any means. I'm just frustrated because this isn't quite the "dead" file type that Adobe thinks it is. What was the point of upgrading if I'm pretty much left in the lurch?
    Thanks to any and all who can help! Much appreciated . -ASI

    adriennesaia a écrit:
    I "upgraded" from Photoshop Elements... uh... mad old... to Elements 13 when my work computer got "upgraded" to Win8. Now I can't open EPS files which is how I receive collateral from our ad agency. What other vector files will work, and how can I convert EPS to these? Please be gentle if this is a stupid question - I know enough to be dangerous, but I'm not an expert at design by any means. I'm just frustrated because this isn't quite the "dead" file type that Adobe thinks it is. What was the point of upgrading if I'm pretty much left in the lurch?
    Thanks to any and all who can help! Much appreciated . -ASI
    What's important to understand is that Elements is a 'pixel' editor, not a 'vector' editor. As such, it has very limited 'vector' capacity (fonts, shapes...) What you are missing from older versions is the ability to convert vector items to standard pixel image file. To be able to open and work on eps files, you'd need Adobe Illustrator, which seems overkill for your purpose.
    So, your options are:
    - to request your ad agency to supply pdf format images instead of eps ones. My guess is that eps is beeing largely superseded by pdf, but I am not sure...
    - Use external tools to convert from eps to jpeg; a Google search would return free softwares like Irfanview or web based conversion.
    - You might want to keep (or reinstall) older Elements versions just for that purpose.

  • What is the best way to convert a cluster into byte array or string

    I'm writing a program that sends UDP packets and I've defined the data I want to send via large clusters (with u8/u16/u32 numbers, u8/u16/u32 arrays, and nested clusters). Right before sending the data, I need to convert the clusters either into strings or byte arrays. The flatten to string function is almost perfect for this purpose. However, it's appending lengths to arrays and strings which renders this method useless, as far as I can tell. 
    As I have many of these clusters, I would rather not hard code the unbundle by names and converting/typecasting to byte arrays or strings for each one. 
    Is there a feature or tool I am overlooking? 
    Thank you! 

    deceased wrote:
    Flatten to string has a boolean input of "Prepend string or array size" ... The default value is true.
    That only specifies if a string or array size should be prepended if the outermost data element is a string or array. For embedded strings or arrays it has no influence. This is needed for the Unflatten to be able to reconstruct the size of the embedded strings and arrays.
    The choice to represent the "Strings" (and Arrays) in the external protocol to LabVIEW strings (and arrays) is actually a pretty bad one unless there is some other element in the cluster that does define the length of the string. An external protocol always needs some means to determine how long the embedded string or array would be in order to decode the subsequent elements that follow correctly.
    Possible choices here are therefore:
    1) some explicit length in the protocol (usually prepended to the actual string or array)
    2) a terminating NULL character for strings, (not very friendly for reliable protocol parsing)
    3) A fixed size array or string
    For number 1) and 2) you would always need to do some special processing unless the protocol happens to use explicitedly 32 bit integer length indicators directly prepended before the variable sized that.
    For number 3) the best representation in LabVIEW is actually a cluster with as many elements inside as the fixed size.
     

Maybe you are looking for