Converting byte[] to Class without using defineClass() in ClassLoader

so as to de-serialize objects that do not have their class definitions loaded yet, i am over-riding resolveClass() in ObjectInputStream .
within resolveClass() i invoke findClass() on a network-based ClassLoader i created .
within findClass() , i invoke
Class remoteClass = defineClass(className, classImage, 0, classImage.length);
and that is where i transform a byte[] into a Class , and then finally return a value for the resolveClass() method.
this seems like a lengthy process. i mean, within resolveClass() i can grab the correct byte[] over the network.
then, if i could only convert this byte[] to a Class within resolveClass() , i would never need to extended ClassLoader and over-ride findClass() .
i assume that the only way to convert a byte[] to a Class is using defineClass() which is hidden deep within ClassLoader ? there is something going on under the hood i am sure. otherwise, why not a method to directly convert byte[] to a Class ? the byte[] representation of a Class always starts with hex CAFEBABE, and then i'm sure there is a standard way to structure the byte[] .
my core issue is:
i am sending objects over an ObjectInputStream created from a Socket .
at the minimum, i can see that resolveClass() within ObjectInputStream must be invoked at least once .
but then after that, since the relevant classes for de-serialization have been gotten over the network, i don't want to cascade all the way down to where i must invoke:
Class remoteClass = defineClass(className, classImage, 0, classImage.length);
again. so, right now, within resolveClass() i am using a Map<String, Class> to create the following class cache:
cache.put(objectStreamClass.getName(), Class);
once loaded, a class should stay loaded (even if its loaded in the run-time), i think? but this is not working. each de-serialization cascades down to defineClass() .
so, i want to short-circuit the need to get the class within the resolveClass() method (ie. invoke defineClass() only once),
but using a Map<String, Class> cache looks really stupid and certainly a hack.
that is the best i can do to explain my issue. if you read this far, thanks.

ok. stupid question:
for me to use URLClassLoader , i am going to need to write a bare-bones HTTP server to handle the class requests, right?Wrong. You have to deploy one, but what's wrong with Apache for example? It's free, for a start.
and, i should easily be able to do this using the com.sun.net.httpserver library, right?Why would you bother when free working HTTP servers are already available?

Similar Messages

  • How to reference a class without using the new keyword

    I need to access some information from a class using the getter, but I don't want to use the new keyword because it will erase the information in the class. How can I reference the class without using the new keyword.
    ContactInfo c = new ContactInfo(); // problem is here because it erases the info in the class
    c.getFirstName();

    quedogf94 wrote:
    I need to access some information from a class using the getter, but I don't want to use the new keyword because it will erase the information in the class. How can I reference the class without using the new keyword.
    ContactInfo c = new ContactInfo(); // problem is here because it erases the info in the class
    c.getFirstName();No.
    Using new does not erase anything. There's nothing to erase. It's brand new. It creates a new instance, and whatever that constructor puts in there, is there. If you then change the contents of that instance, and you want to see them, you have to have maintained a reference to it somewhere, and access that instance's state through that reference.
    As already stated, you seem to be confused between class and instance, at the very least.
    Run this. Study the output carefully. Make sure you understand why you see what you do. Then, if you're still confused, try to rephrase your question in a way that makes some sense based on what you've observed.
    (And not that accessing a class (static) member through a reference, like foo1.getNumFoos() is syntactically legal, but is bad form, since it looks like you're accessing an instance (non-static) member. I do it here just for demonstration purposes.)
    public class Foo {
      private static int numFoos; // class variable
      private int x; // instance varaible
      public Foo(int x) {
        this.x = x;
        numFoos++;
      // class method
      public static int getNumFoos() {
        return numFoos;
      // instance method 
      public int getX() {
        return x;
      public static void main (String[] args) {
        System.out.println ("Foo.numFoos is " + Foo.getNumFoos ());
        System.out.println ();
        Foo foo1 = new Foo(42);
        System.out.println ("Foo.numFoos is " + Foo.getNumFoos ());
        System.out.println ("foo1.numFoos is " + foo1.getNumFoos ());
        System.out.println ("foo1.x is " + foo1.getX ());
        System.out.println ();
        Foo foo2 = new Foo(666);
        System.out.println ("Foo.numFoos is " + Foo.getNumFoos ());
        System.out.println ("foo1.numFoos is " + foo1.getNumFoos ());
        System.out.println ("foo1.x is " + foo1.getX ());
        System.out.println ("foo2.numFoos is " + foo2.getNumFoos ());
        System.out.println ("foo2.x is " + foo2.getX ());
        System.out.println ();
    }

  • Func module to convert list to pdf without using memory id

    hi Experts,
    Is there any funct module to convert list to pdf without using memory, as I am using Convert_to_PDF func module which outputs last page only  when its running in Background.
    But my req is to output all the Pages in the PDF format.
    Sample code also appreciable,
    Reward Points are guranteed..
    Cheers
    Santosh

    Check the below postings :
    Re: Convert spool to pdf
    Convert a spooljob to a writeprotected PDF
    Hope this will helpful

  • Want to find out parent class of a class without using getSuperClass

    hi,
    I am trying to write a code to find out the base class /interfaces of a class by its object and i dont want to use getSuperClass,getInterfaces methods.
    Below is a snippet i tried but it does not work:
    public class Test extends Parent{
    public void disp(){
    System.out.println(super.getClass().getName());
    public static void main(String args[]){
    Test test = new Test();
    test.disp2();
    this outputs the child class only does not output the parent class.
    Is there any method to do so?
    Thanks,
    Anirudh

    Ok, If it can not be done then i must not ask.
    So you have answered it that it is not possible without these.Thats what i wanted to know.
    Should have framed the question like is it possible?and if possible how?
    Thanks
    Anirudh

  • Convert to Transaction Class to Use Market Basket Analysis Script (arules) in the Execute R Script Module

    Hello,
    I need to do Market Basket Analysis for my data, and have a working R script when using it in R Studio.  I need to transfer that R script to Azure ML Studio.  I read in another posting that the arules package is pre-installed and that I need
    to use the Execute R Script module since there is not other built-in module/function that does anything similar to Market Basket.  I went ahead and copy-paste my R script into the module with some slight modifications in terms of importing the data. 
    I use the R function read.transaction to import and convert my data frame (a csv file) into a transaction class directly from my working directory when using R Studio.  It appears that read.transaction does not work on Azure ML, and yet
    I need my data to be in transaction class for the rest of the functions in arules to work.  Therefore, how do I get around this?
    Thank you.

    Thanks.
    This is my R script:
    library(arules)
    library(arulesViz)
    # Contents of optional Zip port are in ./src/
    #source("src/MOD Targeting MBA ML.R");
    Data = read.transactions("src/data.csv", format = "single", sep = ",", cols = c(1,2))
    itemFrequencyPlot(Data, topN = 37, type = "absolute")
    Baskets = apriori(Data, parameter = list(supp = 0.001, conf = 0.8))
    inspect(Baskets)
    Results = as(Baskets, "data.frame")
    maml.mapOutputPort("Results")
    And this is the output log:
    Record Starts at UTC 12/23/2014 19:52:51:
    Run the job:"/dll "ExecuteRScript, Version=6.0.0.0, Culture=neutral, PublicKeyToken=69c3241e6f0468ca;Microsoft.MetaAnalytics.RDataSupport.ExecuteRScript;Run" /Output0 "..\..\Result Dataset\Result Dataset.dataset" /Output1 "..\..\R Device\R Device.dataset" /bundlePath "..\..\Script Bundle\Script Bundle.zip" /rStreamReader "script.R" "
    Starting process 'C:\Resources\directory\c3626c2575d5423e8cb58a9e7230be5e.SingleNodeRuntimeCompute.Packages\AFx\6.0\DllModuleHost.exe' with arguments ' /dll "ExecuteRScript, Version=6.0.0.0, Culture=neutral, PublicKeyToken=69c3241e6f0468ca;Microsoft.MetaAnalytics.RDataSupport.ExecuteRScript;Run" /Output0 "..\..\Result Dataset\Result Dataset.dataset" /Output1 "..\..\R Device\R Device.dataset" /bundlePath "..\..\Script Bundle\Script Bundle.zip" /rStreamReader "script.R" '
    [ModuleOutput] DllModuleHost Start: 1 : Program::Main
    [ModuleOutput] DllModuleHost Start: 1 : DataLabModuleDescriptionParser::ParseModuleDescriptionString
    [ModuleOutput] DllModuleHost Stop: 1 : DataLabModuleDescriptionParser::ParseModuleDescriptionString. Duration: 00:00:00.0050971
    [ModuleOutput] DllModuleHost Start: 1 : DllModuleMethod::DllModuleMethod
    [ModuleOutput] DllModuleHost Stop: 1 : DllModuleMethod::DllModuleMethod. Duration: 00:00:00.0000598
    [ModuleOutput] DllModuleHost Start: 1 : DllModuleMethod::Execute
    [ModuleOutput] DllModuleHost Start: 1 : DataLabModuleBinder::BindModuleMethod
    [ModuleOutput] DllModuleHost Verbose: 1 : moduleMethodDescription ExecuteRScript, Version=6.0.0.0, Culture=neutral, PublicKeyToken=69c3241e6f0468ca;Microsoft.MetaAnalytics.RDataSupport.ExecuteRScript;Run
    [ModuleOutput] DllModuleHost Verbose: 1 : assemblyFullName ExecuteRScript, Version=6.0.0.0, Culture=neutral, PublicKeyToken=69c3241e6f0468ca
    [ModuleOutput] DllModuleHost Start: 1 : DataLabModuleBinder::LoadModuleAssembly
    [ModuleOutput] DllModuleHost Verbose: 1 : Trying to resolve assembly : ExecuteRScript, Version=6.0.0.0, Culture=neutral, PublicKeyToken=69c3241e6f0468ca
    [ModuleOutput] DllModuleHost Verbose: 1 : Loaded moduleAssembly ExecuteRScript, Version=6.0.0.0, Culture=neutral, PublicKeyToken=69c3241e6f0468ca
    [ModuleOutput] DllModuleHost Stop: 1 : DataLabModuleBinder::LoadModuleAssembly. Duration: 00:00:00.0074580
    [ModuleOutput] DllModuleHost Verbose: 1 : moduleTypeName Microsoft.MetaAnalytics.RDataSupport.ExecuteRScript
    [ModuleOutput] DllModuleHost Verbose: 1 : moduleMethodName Run
    [ModuleOutput] DllModuleHost Information: 1 : Module FriendlyName : Execute R Script
    [ModuleOutput] DllModuleHost Information: 1 : Module Release Status : Release
    [ModuleOutput] DllModuleHost Stop: 1 : DataLabModuleBinder::BindModuleMethod. Duration: 00:00:00.0116536
    [ModuleOutput] DllModuleHost Start: 1 : ParameterArgumentBinder::InitializeParameterValues
    [ModuleOutput] DllModuleHost Verbose: 1 : parameterInfos count = 5
    [ModuleOutput] DllModuleHost Verbose: 1 : parameterInfos[0] name = dataset1 , type = Microsoft.Numerics.Data.Local.DataTable
    [ModuleOutput] DllModuleHost Verbose: 1 : Set optional parameter dataset1 value to NULL
    [ModuleOutput] DllModuleHost Verbose: 1 : parameterInfos[1] name = dataset2 , type = Microsoft.Numerics.Data.Local.DataTable
    [ModuleOutput] DllModuleHost Verbose: 1 : Set optional parameter dataset2 value to NULL
    [ModuleOutput] DllModuleHost Verbose: 1 : parameterInfos[2] name = bundlePath , type = System.String
    [ModuleOutput] DllModuleHost Verbose: 1 : parameterInfos[3] name = rStreamReader , type = System.IO.StreamReader
    [ModuleOutput] DllModuleHost Verbose: 1 : parameterInfos[4] name = seed , type = System.Nullable`1[System.Int32]
    [ModuleOutput] DllModuleHost Verbose: 1 : Set optional parameter seed value to NULL
    [ModuleOutput] DllModuleHost Stop: 1 : ParameterArgumentBinder::InitializeParameterValues. Duration: 00:00:00.0102003
    [ModuleOutput] DllModuleHost Verbose: 1 : Found trace source in Execute R Script module...
    [ModuleOutput] DllModuleHost Verbose: 1 : Begin invoking method Run ...
    [ModuleOutput] Microsoft Drawbridge Console Host [Version 1.0.2108.0]
    [ModuleOutput] [1] 56000
    [ModuleOutput]
    [ModuleOutput] The following files have been unzipped for sourcing in path=["src"]:
    [ModuleOutput]
    [ModuleOutput] Name Length Date
    [ModuleOutput]
    [ModuleOutput] 1 data.csv 2875965 2014-12-04 17:08:00
    [ModuleOutput]
    [ModuleOutput] 2 __MACOSX/ 0 2014-12-23 09:39:00
    [ModuleOutput]
    [ModuleOutput] 3 __MACOSX/._data.csv 120 2014-12-04 17:08:00
    [ModuleOutput]
    [ModuleOutput] Loading objects:
    [ModuleOutput]
    [ModuleOutput] Loading required package: Matrix
    [ModuleOutput]
    [ModuleOutput]
    [ModuleOutput]
    [ModuleOutput] Attaching package: 'arules'
    [ModuleOutput]
    [ModuleOutput]
    [ModuleOutput]
    [ModuleOutput] The following objects are masked from 'package:base':
    [ModuleOutput]
    [ModuleOutput]
    [ModuleOutput]
    [ModuleOutput] %in%, write
    [ModuleOutput]
    [ModuleOutput]
    [ModuleOutput]
    [ModuleOutput] Loading required package: grid
    [ModuleOutput]
    [ModuleOutput]
    [ModuleOutput] Attaching package: 'arulesViz'
    [ModuleOutput]
    [ModuleOutput] The following object is masked from 'package:base':
    [ModuleOutput]
    [ModuleOutput] abbreviate
    [ModuleOutput]
    [ModuleOutput] $value
    [ModuleOutput] NULL
    [ModuleOutput]
    [ModuleOutput] $visible
    [ModuleOutput] [1] FALSE
    [ModuleOutput]
    [ModuleOutput] Warning messages:
    [ModuleOutput] 1: In strptime(x, format, tz = tz) :
    [ModuleOutput] unable to identify current timezone 'C':
    [ModuleOutput] please set environment variable 'TZ'
    [ModuleOutput] 2: In strptime(x, format, tz = tz) : unknown timezone 'localtime'
    [ModuleOutput] DllModuleHost Stop: 1 : DllModuleMethod::Execute. Duration: 00:00:14.5396895
    [ModuleOutput] DllModuleHost Error: 1 : Program::Main encountered fatal exception: Microsoft.Analytics.Exceptions.ErrorMapping+ModuleException: Error 0063: The following error occurred during evaluation of R script:
    [ModuleOutput] ---------- Start of error message from R ----------
    [ModuleOutput] Error: Mapped variable must be of class type data.frame at this time.
    [ModuleOutput]
    [ModuleOutput]
    [ModuleOutput] Error: Mapped variable must be of class type data.frame at this time.
    [ModuleOutput] ----------- End of error message from R -----------
    Module finished after a runtime of 00:00:14.6091783 with exit code -2
    Module failed due to negative exit code of -2
    Record Ends at UTC 12/23/2014 19:53:07.
    Sorry, it won't let me send a link for some reason.
    Thanks.
    Cindy

  • Is it possbile to create ALV Grid using Class &  without using SE51

    Is it possible to create a alv grid using Class, with out using the screen painter(SE51).

    Hi Preethi,
    It is possible to creat ALV grid using class, provided u have to create a custom control in the screen dialog.
    Try with the foll code. This is an example for flight detail.
    DATA: container TYPE REF TO cl_gui_custom_container,
          alv_con TYPE REF TO cl_gui_alv_grid.
    data : it_sflight like table of wa with header line,
           g_fieldcat type lvc_t_fcat.
    /* Paste the code the PBO
        CREATE OBJECT container
          EXPORTING
            container_name              = 'C_SPFLI'. "Specify the container name which u created in the dialog screen.
        CREATE OBJECT alv_con
          EXPORTING
            i_parent          = container.
    /* Use the foll. to dislay the report
    CALL METHOD cl_grid->set_table_for_first_display
            EXPORTING
             I_STRUCTURE_NAME              = 'SFLIGHT'
            CHANGING
              it_outtab                     = it_sflight[]
              IT_FIELDCATALOG               = g_fieldcat.
    First create the container and then place the ALV in the container and for dislaying pass the necessary table.
    Hope this will useful for u.
    Get back if u r unable to do it.
    Regards
    Router

  • HOW TO CONVERT EIGRP TO OSPF WITHOUT USING ROUTE REDISTRIBUTION?

    Please help me on that...       

    try like this.
    data : year(4),
             mon(2),
    day(2).
    in itab declare field cbudat(8) type c.
    loop at itab.
    year = itab-budat(4).
    mon = itab-budat+4(2).
    day = itab-budat+6(2).
    concatenate year mon day into itab-cbudat.
    modify itab.
    endloop.
    now use select for all entries and check gdatu = itab-cbudat.
    regards
    shiba dutta

  • Converting bytes to shorts using arrays and NIO buffers - is this a bug?

    I'm benchmarking the various methods for converting a sequence of bytes into shorts. I tried copying a byte array, a direct NIO buffer and a non-direct NIO buffer to a short array (using little-endian byte order). My results were a little confusing to me. As I understand it, direct buffers are basically native buffers - allocated by the OS instead of on the runtime's managed heap, hence their higher allocation cost and ability to perform quicker IO with channels that can use them directly. I also got the impression that non-direct buffers (which have a backing array) are basically just regular Java arrays wrapped in a ByteBuffer.
    I didn't expect a huge difference between the results of my three tests, though I thought the two NIO methods might perform a bit quicker if the virtual machine was smart enough to notice that little-endian is my system's native byte order (hence allowing the chunk of memory to simply be copied, rather than applying a bunch of shifts and ORs to the bytes). Conversion with the direct NIO buffer was indeed faster than my byte array method, however the non-direct NIO buffer performed over ten times slower than even my array method. I can see it maybe performing a millisecond or two slower than the array method, what with virtual function call overhead and a few if checks to see what byte order should be used and what not, but shouldn't that method basically be doing exactly the same thing as my array method? Why is it so horribly slow?
    Snippet:
    import java.nio.*;
    public class Program {
      public static final int LOOPS = 500;
      public static final int BUFFER_SIZE = 1024 * 1024;
      public static void copyByteArrayToShortArrayLE(byte[] buffer8, short[] buffer16) {
        for(int i = 0; i < buffer16.length; i += 2){
          buffer16[i >>> 1] = (short) ((buffer8[i] & 0xff) | ((buffer8[i + 1] & 0xff) << 8));
      public static void main(String[] args) {
        short[] shorts = new short[BUFFER_SIZE >>> 1];
        byte[] arrayBuffer = new byte[BUFFER_SIZE];
        ByteBuffer directBuffer = ByteBuffer.allocateDirect(BUFFER_SIZE).order(ByteOrder.LITTLE_ENDIAN);
        ByteBuffer nonDirectBuffer = ByteBuffer.allocate(BUFFER_SIZE).order(ByteOrder.LITTLE_ENDIAN);
        long start;
        start = System.currentTimeMillis();
        for(int i = 0; i < LOOPS; ++i) copyByteArrayToShortArrayLE(arrayBuffer, shorts);
        long timeArray = System.currentTimeMillis() - start;
        start = System.currentTimeMillis();
        for(int i = 0; i < LOOPS; ++i) directBuffer.asShortBuffer().get(shorts);
        long timeDirect = System.currentTimeMillis() - start;
        start = System.currentTimeMillis();
        for(int i = 0; i < LOOPS; ++i) nonDirectBuffer.asShortBuffer().get(shorts);
        long timeNonDirect = System.currentTimeMillis() - start;
        System.out.println("Array:      " + timeArray);
        System.out.println("Direct:     " + timeDirect);
        System.out.println("Non-direct: " + timeNonDirect);
    }Result:
    Array:      328
    Direct:     234
    Non-direct: 4860

    Using JDK1.6.0_18 on Ubuntu 9.1 I typically get
    Array: 396
    Direct: 550
    Non-direct: 789
    I think your tests are a little too short for accurate timings because they are likely to be significantly influenced by the JIT compilation.
    If I change to use a GIT warmup i.e.
    public static final int LOOPS = 500;
        public static final int WARMUP_LOOPS = 500;
        public static final int BUFFER_SIZE = 1024 * 1024;
        public static void copyByteArrayToShortArrayLE(byte[] buffer8, short[] buffer16)
            for (int i = 0; i < buffer16.length; i += 2)
                buffer16[i >>> 1] = (short) ((buffer8[i] & 0xff) | ((buffer8[i + 1] & 0xff) << 8));
        public static void main(String[] args)
            short[] shorts = new short[BUFFER_SIZE >>> 1];
            byte[] arrayBuffer = new byte[BUFFER_SIZE];
            ByteBuffer directBuffer = ByteBuffer.allocateDirect(BUFFER_SIZE).order(ByteOrder.LITTLE_ENDIAN);
            ByteBuffer nonDirectBuffer = ByteBuffer.allocate(BUFFER_SIZE).order(ByteOrder.LITTLE_ENDIAN);
            long start = 0;
            for (int i = -WARMUP_LOOPS; i < LOOPS; ++i)
                if (i == 0)
                    start = System.currentTimeMillis();
                copyByteArrayToShortArrayLE(arrayBuffer, shorts);
            long timeArray = System.currentTimeMillis() - start;
            for (int i = -WARMUP_LOOPS; i < LOOPS; ++i)
                if (i == 0)
                    start = System.currentTimeMillis();
                directBuffer.asShortBuffer().get(shorts);
            long timeDirect = System.currentTimeMillis() - start;
            for (int i = -WARMUP_LOOPS; i < LOOPS; ++i)
                if (i == 0)
                    start = System.currentTimeMillis();
                nonDirectBuffer.asShortBuffer().get(shorts);
            long timeNonDirect = System.currentTimeMillis() - start;
            System.out.println("Array:      " + timeArray);
            System.out.println("Direct:     " + timeDirect);
            System.out.println("Non-direct: " + timeNonDirect);
        }then I typically get
    Array: 365
    Direct: 528
    Non-direct: 750
    and if I change to 50,000 loops I typically get
    Array: 37511
    Direct: 57199
    Non-direct: 73913
    You also seem to have a bug in your copyByteArrayToShortArrayLE() method. Should it not be
    public static void copyByteArrayToShortArrayLE(byte[] buffer8, short[] buffer16)
            for (int i = 0; i < buffer8.length; i += 2)
                buffer16[i >>> 1] = (short) ((buffer8[i] & 0xff) | ((buffer8[i + 1] & 0xff) << 8));
        }Edited by: sabre150 on Jan 27, 2010 9:07 AM

  • How to convert mm/dd/yy to dd/mm/yy in ABAP PROGRMS without using offsets

    how to convert mm/dd/yy to dd/mm/yy in ABAP PROGRMS without using offsets

    Do this way..
    data: lv_date(8)   type c.
    write sy-datum to lv_date DD/MM/YY.
    or
    write:/ sy-datum using edit mask '__/__/__'
    Regards,
    Santosh
    Message was edited by:
            Santosh Kumar Patha

  • How to convert a open item become cleared item without using F-32

    Dear experts,
    Can I convert an open item become clear item without using F-32.
    Please help.

    Hi,
    You can use F-28.
    If it's useful assign points
    Thanks&Regards,
    Kumar

  • Using text in a GUI without using .swing classes

    In a Java application, is there any way to create a text object that can be positioned in a GUI like an ImageIcon (using a class from the standard Java API)? For example, when using ImageIcon, you feed the x and y-coordinates, whereas with .swing, you'd have to create a new panel, position the panel, and re-position the panel using BorderLayout.(direction).
    Ex. (with ImageIcon, you'd place it like so):
    //construct ImageIcon w/ URL
    ImageIcon myImage = new ImageIcon(new URL("http://..."));
    //x and y are pixels to the right and to the bottom from the top left corner
    myImage.paintIcon( (Component), (Graphics), x, y);
    //I'm looking for one that does the same, like this (without using an image, preferrably), TextMessage is what the class might be:
    TextMessage myText = new TextMessage("Here is some string to print out");
    myText.printText( (Component), (Graphics), x, y)

    or you can paint a string, like this
    public void paint(Graphics g) {
         super.paint(g);
         g.drawString("Hello World!", x,y);  // replace x, y with your own coordinates
    }hope that helps

  • How to add byte[] array based Image to the SQL Server without using parameter

    how to add byte[] array based Image to the SQL Server without using parameter.I have a column in table with the type image in sql and i want to add image array to the sql image column like below:
    I want to add image (RESIM) to the procedur like shown above but sql accepts byte[] RESIMI like System.Drowing. I whant that  sql accepts byte [] array like sql  image type
    not using cmd.ParametersAdd() method
    here is Isle() method content

    SQL Server binary constants use a hexadecimal format:
    https://msdn.microsoft.com/en-us/library/ms179899.aspx
    You'll have to build that string from a byte array yourself:
    byte[] bytes = ...
    StringBuilder builder = new StringBuilder("0x", 2 + bytes.Length * 2);
    foreach (var b in bytes)
    builder.Append(b.ToString("X2"));
    string binhex = builder.ToString();
    That said, what you're trying to do - not using parameters - is the wrong thing to do. Not only it is insecure due to the risk of SQL injection but in the case of binary data is also inefficient since these hex strings are larger than the original byte[]
    data.

  • Converting a class for use in a jsp page.

    I was just wondering if it is possible/normal to convert complex(ish) classes to change the output from the system.out, to a return value from a method that is displayed via a jsp page. (I am just beginning, and trying to make the coversion from asp with COM to jsp with beans/servlets and I am not yet fully understanding the technologies, and how you import classes etc - please bear with me!)
    first, I made a class that has a method that just returns a string. like:
         public String GetAValue()
              return "Hello there.";
         }and then I made a jsp page that imported the class (test) like:
    <%@ page import="Test" %>
    <jsp:useBean id="tst" scope="page" class="Test" />
    st = tst.GetAValue();
    out.println(st);
    Which to my delight, worked fine! Then I made another class that retrieved a value from a web service. kind of like...
         public String GetAValueFromAWebService(){
              return theWebService.GetValueFromWebServiceMethod();
         }This class also works good when I just run via "java testit". But when I went to do the same as above ,ie, import the class, do a usebean then do st=tst2.GetValueFromWebServiceMethod(), I could not get it to work at all. This class does lots more tricky stuff then the first one though - it loads its properties from a .properties file via an instance of another class, and imports funky stuff like - import org.uddi4j.* and import java.util.Vector; and more.
    Ok, now the question! Is what I am trying to do stupid? If so, how should I do it? If its not stupid, how do I include all the extra import statements on the jsp page (there are about 10)
    Wow, sorry about the length of this post. I hope someone can understand my ramblings!
    Thanks,
    nmoog.

    Sorry, yeah...
    I am actually using the UDDI4J package, and it loads various settings with the
    config = Configurator.load(); (a seperate class to load stuff in with)
    The Configurator.Load method basically just does:
    config.load(new java.io.FileInputStream("samples.prop"));
    and then does System.setProperty() with the config.getProperty()
    values.
    I have a test class when I do "java Test" it runs and in the Main method just instantiates the MyWebService class and does the MyWebService.GetAWebServiceValue() which returns a string.
    As I said, this runs fine. But from the JSP code if I do the same thing it gets a NullPointerException.
    "java.lang.NullPointerException
    at java.util.Hashtable.put(Hashtable.java:389)
    at java.util.Properties.setProperty(Properties.java:102)
    at java.lang.System.setProperty(System.java:654)
    at Configurator.load(Configurator.java:43)"
    Why can it load okie-dokey from the test class, but not the jsp page? Any ideas?

  • Can I charge my Ipad in europe without using a voltage converter?

    Can I charge my Ipad in Europe without using a voltage converter?

    Just spent 10 days in Ireland with our recently-purchased iPad and had no trouble charging it with the proper adaptor. NOTE: The UK uses a different adapter than continental Europe. Make sure you have the right adaptor for the counties you will visit. This article is helpful:
    http://en.wikipedia.org/wiki/AC_power_plugs_and_sockets

  • Using Custom Legend without Using Legend Class for line Chart

    Hi ,
    I m trying to create legend with checkbox without using Legend class of flex, but problem is that how to use itemrenderer of lineseries in the legend.
    My requirement is like this:

    my problemb is how to get that shape and use in container .
    i am using hbox in that i have checkbox ,label and i tried to use Image or IFlexDisplayObject but i am unable to assign that renderer to either  image or IFlexDisplayOBject nothing isd working.
    any suggestion for what component i shall use to assign the itemrenderer of lineseries.
    Thanks for replying

Maybe you are looking for

  • Update material doc.num in assignment field of GR/IR line item of a/c doc

    HI Experts, please tell me the solution for my problem My requirement : Transaction is : MIGO Before posting of material document, update material document number in assignment field of GR/IR line item of accounting document (WE) at number commitment

  • How to restore an icloud device after removing it

    when I loss my iphone a friend one ask me to remove it from icloud on my macbookpro and that it would re-appear when someone try my phone again. I wish i hadn't done it because find my iphone app when i go to icloud on my computer has been showing ev

  • Best router for compatability with Mac & Airport Express?

    I need to buy a wireless router, and know little about them. This will be for home use, and will be used for 2 people with their own computers. Distance is not a factor, as it's just a regular house, although the router may have to be placed in the g

  • How to remove Path in Save As action?

    I have some deifned actions in CS4. At one point I would like to save the file at a pre-defined quality. When I record that Save As part it also stores the path where to save the file to. I would like to remove that path. How can I do it?

  • Assign the quality type =01 at material type level

    Hi, I am working with quality Management , Here Client want to all Raw material is check at time of receiving .So We want to Assign the quality type =01 at material type level . How we can do that?? Individual Material assignment is not possible beca