Problem in reading/writing byte array in Access database! PLEASE HELP!!

Hi,
I want to store a signature, which is in form of a byte array, in OLE Object field in MS Access database. I want then to retrieve this signature and verify it. The problem is that the retrieved byte array is not identical to the stored (original) one, and therefore, verifying the signature fails! Any help would be much appreciated as I can't proceed in my project without solving this problem. Here is the code to do the above mentioned functionality:
//This part stores the signature (VT) in the table TTPTrans
try
{ con = connect();
ps = con.prepareStatement("UPDATE TTPTrans SET VT = ?, SigVT = ? WHERE TransID = ?");
ps.setBinaryStream(1, new ByteArrayInputStream(vt), vt.length);
ps.setBinaryStream(2, new ByteArrayInputStream(sigvt), sigvt.length);
ps.setString(3, tID);
ps.executeUpdate();
ps.close();
con.close();
catch (Exception e)
{  System.err.println(e.getMessage());
e.printStackTrace();
//This part retrive the signature from the table in the byte array o1:
ResultSet result;
byte[] o1 = null;
byte[] o2 = null;
try
{ con = connect();
Statement statement = con.createStatement();
result = statement.executeQuery("SELECT VT, SigVT" +
" FROM TTPTrans" +
" WHERE TransID = " + "'" +
transID + "'");
while (result.next()) {
o1 = result.getBytes("VT");
o2 = result.getBytes("SigVT");
statement.close();
con.close();
catch(Exception e)
{ System.err.println(e.getMessage());
e.printStackTrace();
}

In the following code, I use a ASN1SDSSSignature class, which is a subclass that I created from the Siganture class, to create and verify an SDSS signature. The ASN1SDSSSignature has two ASN1Integer class variables:
signcryption = token.getSigncryption();
sig.initVerify(ttpCert);
sig.update(receivedVT);
boolean verified = sig.verify(receivedSigVT);
if(!verified)
System.err.println("TTP signatire on received token invalid. ");
notify()
return;
Where receivedVT and receivedSigVT are the byte arrays retrieved from th database. The following exception is thrown when I run the application:
ASN1 type mismatch!
Expected: codec.asn1.ASN1Integer
In: ASN1SDSSSignature
At index 0
Got tag: 4 and Class: 0
I hope this would clarify the situation and thanks in advance for any comments you may post.

Similar Messages

  • Hello, I have a problem with my Yahoo Messenger, I can't join in chatroom. It's prompting like "yahoo error, you've been refused to access"..please help me..thanks

    Hello, I have a problem with my Yahoo Messenger, I can't join in chatroom. It's prompting like "yahoo error, you've been refused to access"..please help me..thanks

    post in a yahoo messenger forum.  These forums are for apple products and software.

  • After I updated lion to 10.7.4, app store does not recognize my ID APPLE and it unable to connect me to app store in order to update/download apps? What have I to do? I have the same problem with mac mini e mac book air. Please help me!

    After I updated lion to 10.7.4, app store does not recognize my ID APPLE and it unable to connect me to app store in order to update/download apps? What have I to do? I have the same problem with mac mini e mac book air. Please help me!

    Your advice did not help me. I also installed 10.7.4 combo but the situation is the same.
    my internet connection is ok, mail is ok, but app store after 3 resets does not recognize my ID and it says "connection is not possible". Why? I have the same problem in both my mac mini late 2009 and mac book air 2010? Is it a problem of 10.7.4 update? I have to solve this problem and how can i return to 10.7.3 if my last backup was not with 10.7.3???thank you for your kind collaboration...

  • My iPhone 4S . the restore Ends at 60 % with error 1 (not -1). I reinstall iTunes, download iOS 7.0.3 as ipsw and No success :(   I Think that is a problem of the iTunes or firmware versions :/.   Apple Please Help us!

    my iPhone 4S the restore Ends at 60 % with error 1 (not -1).
    I reinstall iTunes, download iOS 7.0.1 as ipsw and No success
    I Think that is a problem of the iTunes or firmware versions :/.
    Apple Please Help us!

    You can't Restore to any iOS other than 7.1.
    If the error persists, try on another computer. Still no joy, it is a hardware failure.

  • After installed mavericks i cannot sign in to my facetime and i messages. i tried it 100 times, but it is showing couldn't sign in check your network and try again. there is no problem with my network. if anyone knows the solution please help me .

    After installed mavericks i cannot sign in to my facetime and i messages. i tried it 100 times, but it is showing couldn't sign in check your network and try again. there is no problem with my network. if anyone knows the solution please help me .

    Hi,
    What version of the OS did you upgrade from ?
    Anything before OS X 10.8.2 may have an issue if the Logic/Mother board has been replaced and the Serial Number not "flashed" back to it.
    In the Apple Icon menu use the About this Mac item.
    In the new panel click twice on the line that tells you the current OS level
    It will change to the Build number (and alternative count to the OS versions) and then the Serial Number.
    If it is missing you need to get it replaced.
    (It is supposed to be done on Repair or Refurbishment).
    An Apple Store or Apple Authorised Service Provider as the best choices.
    There are apps you can download (They are Mac Model specific) but needs careful typing as it is a once only trip.
    8:56 pm      Sunday; November 24, 2013
      iMac 2.5Ghz 5i 2011 (Mavericks 10.9)
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb (Snow Leopard 10.6.8)
     Mac OS X (10.6.8),
     Couple of iPhones and an iPad
    Message was edited by: Ralph Johns (UK)

  • I am having a problem converting word onto PDF . PDF into word.Please help .I am signed and paid to Feb 2015

    Can someone advise me why I am having this problem

    Always in the past .I have my Word Document on screen and then I go to 
    Publish and it atomatically PDF the doc.
    The same if I have a PDF to convert to word. I have the PDF on screen and 
    to the right of my screen it will say Convert .I press on convert it
    converts to  word
    In a message dated 12/17/2014 10:01:32 A.M. Eastern Standard Time, 
    [email protected] writes:
    I  am having a problem converting word onto PDF . PDF into word.Please help
    .I am signed and paid to Feb 2015
    created by florencejohn (https://forums.adobe.com/people/florencejohn) 
    in  Adobe Acrobat.com Services - View the full  discussion
    (https://forums.adobe.com/message/7023171#7023171)

  • Spinwheel when syncing, unable to sync photos, error message "the disk cannot be read from or written to" ... please help!

    spinwheel when syncing, unable to sync photos, error message "the disk cannot be read from or written to" ... please help!

    Everytime I try to sync my photos to iPad or my iPhone. The sync freezes for a whilie then comes back with "the disk cannot be read from or written to". I have already exported photo library from iPhoto and readded the photos.

  • I need help with a PDF file that is an image, the "Read Out Loud' option does not work, please help!

    I need help with a PDF file that is an image, the "Read Out Loud' option does not work, please help!

    You mean an image such as a scanned document?
    If that is the case, the file doesn't contain any text for Reader Out Loud to read. In order to fix that, you would need an application such as Adobe Acrobat that does Optical Character Recognition to convert the images to actual text.
    You can also try to export the file as a Word document or something else using ExportPDF which I believe offers OCR and is cheaper than Acrobat.

  • I have an account in Apple Astor was not able to access it, please help me in this matter

    I have an account in Apple Astor was not able to access it, please help me in this matter
    <E-mail Edited by Host>

    What to do if your iPhone will not turn on

  • I have iphone 3gs and it keeps shut dowm by itself every two minutes idunno if this problem related to the battery life or what? please help me solve this problem

    i have iphone 3gs and it keeps shut dowm by itself every two minutes idunno if this problem related to the battery life or what? please help me solve this problem

    See Here for Device continually restarts...
    http://support.apple.com/kb/HT1808

  • My computer crashed before i was able to deactivate my Visual Communicator 3 software.  Please help!  I have my disc, but cannot activate my software again.  I have several projects that I cannot access. Please help!

    My computer crashed before I was able to deactivate my Visual Communicator 3 software.  Please help!  I have my disc, but cannot activate my program again.  I have projects that I cannot access. Please help!

    I wish I could help, but I am in a similar situation.
    I need to deactivate it because we are getting rid of the computer it is on and are buying a new one. When I go to Help there is no Deactivate option. The only options are: "Help", "Hide Coach", "Tip of the Day", "Adobe Website", "Technical Support Website", "Frequently Asked Questions", "Check for Updates", "Register", "Download e-License..." (Greyed out), "Return e-License..." (Greyed out) and "About Adobe Visual Communicator 3". I spoke with support through chat and they said my product was no longer supported.
    Patrick

  • How to Read Java Byte Array back into SAP xstring Table?

    Hi Guys,
    I have a situation whereby a user can upload a document in a WebDynpro Java Application.  This needs to be saved.  I am trying to see if I can make the location of this file that is being saved to be on our SAP AS.  I have written a SAP RFC that is imported into the Java Application for use.
    The RFC is expecting a table of type TBL1024 which is basically a table of xstring values.  The Java proxy interprets this SAP table as a byte array.  This is my problem... I cannot seem to "break" up the Byte array into lines of 1024 lengt and send it back to SAP.  All that is happening currently is that the byte array creates a singe line in the TBL1024 that consists of only the first 1024 bytes in the array...  This means that only the first 1024 bytes of my document is being saved - making it corrupt.
    Please advise,
    Kind regards,
    Christiaan

    Loop it...
    File file = new File("java.pdf");
    FileInputStream fis = new FileInputStream(file);
    byte[] buf = new byte[1024];
            try {
                for (int readNum; (readNum = fis.read(buf)) != -1;) {
                    // Here populate the RFC table               
            } catch (IOException ex) {

  • Socket problem with reading/writing - server app does not respond.

    Hello everyone,
    I'm having a strange problem with my application. In short: the goal of the program is to communicate between client and server (which includes exchange of messages and a binary file). The problem is, when I'm beginning to write to a stream on client side, server acts, like it's not listening. I'd appreciate your help and advice. Here I'm including the source:
    The server:
    import java.io.IOException;
    import java.net.ServerSocket;
    public class Server
        public static void main(String[] args)
            ServerSocket serwer;
            try
                serwer = new ServerSocket(4443);
                System.out.println("Server is running.");
                while(true)
                    ClientThread klient = new ClientThread(serwer.accept());
                    System.out.println("Received client request.");
                    Thread t = new Thread(klient);
                    t.start();
            catch(IOException e)
                System.out.print("An I/O exception occured: ");
                e.printStackTrace();
    }ClientThread:
    import java.io.BufferedInputStream;
    import java.io.BufferedOutputStream;
    import java.io.ByteArrayOutputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.OutputStream;
    import java.net.Socket;
    import java.net.SocketException;
    public class ClientThread implements Runnable
        private Socket socket;
        private BufferedInputStream streamIn;
        private BufferedOutputStream streamOut;
        private StringBuffer filePath;
        ClientThread(Socket socket)
                this.socket = socket;     
        public void run()
            try
                 this.streamIn = new BufferedInputStream(socket.getInputStream());
                 this.streamOut = new BufferedOutputStream(socket.getOutputStream());
                int input;
                filePath = new StringBuffer();
                System.out.println("I'm reading...");
                while((input = streamIn.read()) != -1)
                     System.out.println((char)input);
                     filePath.append((char)input);
                this.streamOut.write("Given timestamp".toString().getBytes());
                ByteArrayOutputStream bufferingArray = new ByteArrayOutputStream();
                  while((input = streamIn.read()) != -1)
                       bufferingArray.write(input);
                  bufferingArray.close();
                OutputStream outputFileStream1 = new FileOutputStream("file_copy2.wav");
                  outputFileStream1.write(bufferingArray.toByteArray(), 0, bufferingArray.toByteArray().length);
                  outputFileStream1.close();
                this.CloseStream();
            catch (SocketException e)
                System.out.println("Client is disconnected.");
            catch (IOException e)
                System.out.print("An I/O exception occured:");
                e.printStackTrace();
        public void CloseStream()
            try
                this.streamOut.close();
                this.streamIn.close();
                this.socket.close();
            catch (IOException e)
                System.out.print("An I/O exception occured:");
                e.printStackTrace();
    }The client:
    import java.io.*;
    public class Client
         public static void main(String[] args) throws IOException
              int size;
              int input;
              //File, that I'm going to send
              StringBuffer filePath = new StringBuffer("C:\\WINDOWS\\Media\\chord.wav");
              StringBuffer fileName;
              InputStream fileStream = new FileInputStream(filePath.toString());
            Connect connection = new Connect("127.0.0.1", 4443);
            String response = new String();
            System.out.println("Client is running.");
              size = fileStream.available();
              System.out.println("Size of the file: " + size);
            fileName = new StringBuffer(filePath.substring(filePath.lastIndexOf("\\") + 1));
            System.out.println("Name of the file: " + fileName);
            connection.SendMessage(fileName.toString());
            response = connection.ReceiveMessage();
            System.out.println("Server responded -> " + response);
            ByteArrayOutputStream bufferingArray = new ByteArrayOutputStream();
              while((input = fileStream.read()) != -1)
                   bufferingArray.write(input);
              bufferingArray.close();
            FileOutputStream outputFileStream1 = new FileOutputStream("file_copy1.wav");
              outputFileStream1.write(bufferingArray.toByteArray(), 0, bufferingArray.toByteArray().length);
              outputFileStream1.close();
              byte[] array = bufferingArray.toByteArray();
              for (int i = 0; i < array.length; ++i)
                   connection.streamOut.write(array);
              response = connection.ReceiveMessage();
    System.out.println("Server responded -> " + response);
    connection.CloseStream();
    Connect class:import java.io.*;
    import java.net.Socket;
    import java.net.UnknownHostException;
    public class Connect
    public Socket socket;
    public BufferedInputStream streamIn;
    public BufferedOutputStream streamOut;
    Connect(String host, Integer port)
    try
    this.socket = new Socket(host, port);
    this.streamIn = new BufferedInputStream(this.socket.getInputStream());
    this.streamOut = new BufferedOutputStream(this.socket.getOutputStream());
    catch (UnknownHostException e)
    System.err.print("The Host you have specified is not valid.");
    e.getStackTrace();
    System.exit(1);
    catch (IOException e)
    System.err.print("An I/O exception occured.");
    e.getStackTrace();
    System.exit(1);
    public void SendMessage(String text) throws IOException
    this.streamOut.write(text.getBytes());
    System.out.println("Message send.");
    public void SendBytes(byte[] array) throws IOException
         this.streamOut.write(array, 0, array.length);
    public String ReceiveMessage() throws IOException
         StringBuffer elo = new StringBuffer();
         int input;
         while((input = streamIn.read()) != -1)
              elo.append((char)input);
         return elo.toString();
    public void CloseStream()
    try
    this.streamOut.close();
    this.streamIn.close();
    this.socket.close();
    catch (IOException e)
    System.err.print("An I/O exception occured: ");
    e.printStackTrace();

    The problem that was solved here was a different problem actually, concerning different source code, in which the solution I offered above doesn't arise. The solution I offered here applied to the source code you posted here.

  • Reading/Writing Data from a SQL Database

    Hi,
    I have a data structure called 'Quote' which contains a number of different variables and controls ranging from text boxes, check boxes and radio buttons, i need to be able to read and write this from a database.
    First I think a description of my overall project is needed:
    Project Description
    I have been given a brief that basically says: i have to create a programmed solution in VB to solve a problem. This problem can be anything we like, and I personally have chosen to create a program that manages quotes for building Log Cabins (this is very contrived and far from anything someone would do in the real world).
    My solution will allow a generic user to create a quote (using a form with controls such as text boxes, check boxes, radio buttons) , and then save this to file. These users may then wish to load/edit this quote at a later date, from another form.
    Whilst completing this project, i'll only have up to about 5 records (quotes) within the system, so i dont need the ability to store hundreds of records. And each record will be relatively short, with only about 10-15 data items within the data structure.
    Also the Admin (or business owner in this case) need to be able to view all saved quotes in a presentable format, and edit them if needs be, from within this same program.
    This solution does not need to be absolutely perfect and 100% efficiently coded, or have all the bells and whistles a real-world program would have. This is for an A level computing project by the way.
    So basically, i need to be able to read from the database (to populate a Data Grid (i imagine this is best way?)) and so Admin can access any quote and edit it (editing is not vital, but viewing/printing is. Maybe i should stop at just viewing any quote?). Also i need generic users to be able to fill in the Edit Quote form and then save this data into the database.
    And is a data structure really required for me to use a database?
    I've never used databases in VB before (but have used them elsewhere, mainly Access) and so am completely new to this. Any help will be much appreciated.
    Thanks

    this is just a dataset i created using the dataset designer.
    OK, so i have the dataset called "MyDataSet".
    I also have the following variables:
    Code Snippet
    Dim FloorSpace As Int32
    Dim NoOfBedrooms As Int32
    Dim NoOfBathrooms As Int32
    Dim EnSuites As Int32
    Dim LuxKitchen As Boolean
    Dim LuxCabin As Boolean
    Dim Flooring As Boolean
    Dim VoiceLighting As Boolean
    Dim SolarPanels As Boolean
    Dim IntegralSound As Boolean
    Dim WindowFrames As String
    Each of which relates directly to a column in the dataset (data type matches too).
    What i need to do now, is to save these variables as an additional record in MyDataSet. And then save MyDataSet to file, so it can be loaded again next time the program is run and more additional records added. (all files are local by the way).
    how would i go about this?

  • Problems inputing data through JOptionpane to a Access Database

    I am kinda stuck at how to input a new order through JOptionpane's that adds new information into a MS Access Database. I have been fine with coding to get an order through a search JOptionpane as shown below:
    if (e.getSource() == btnCheckOrder)
    String strInput=JOptionPane.showInputDialog("Enter an order number");
    LinkedList Orders = Xenon.findOrders((long)Integer.parseInt(strInput));
    if(Orders==null)
    txtDisplay.setText("No Results Found! Please Try Again!");
    else
    txtDisplay.setText(Orders.toString());
    Any help or advice on how to solve this problem would be great, as im at my wits end.

    So far i have came up with this in my GUI class:
    if (e.getSource()== btnAddOrder)
    String Orders = JOptionPane.showInputDialog(this,"Order Number", "New Order Number",JOptionPane.INFORMATION_MESSAGE);
    if (Orders == null)
    return;
    String strInput = JOptionPane.showInputDialog("Customer Number", "Enter Customer Number");
    long CustNum = 0;
    strInput = JOptionPane.showInputDialog("Part Number", "Enter Part Number");
    long part_Num = 0;
         strInput = JOptionPane.showInputDialog("Number Ordered", "Enter Number Ordered");
    long Num_Ordered = 0;
         strInput = JOptionPane.showInputDialog("Quoted Price", "Enter Quoted Price");
    double Quoted_Price = 0;
         strInput = JOptionPane.showInputDialog("Order Date", "New Order Date");
    long OrderDate = 0;
         strInput = JOptionPane.showInputDialog("Rep Number", "Enter Rep Number");
    long repNum = 0;
    confirmDialog = new JDialog((Frame) null,"Dialog",true);
    Container dialogContentPane = confirmDialog.getContentPane();
    dialogContentPane.setLayout(new FlowLayout());
    JButton okButton = new JButton("OK");
    okButton.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e ){confirmDialog.dispose();}
    dialogContentPane.add(new JLabel("Confirm New Order"));
    dialogContentPane.add(okButton);
    confirmDialog.setBounds(150,150,150,120);
    confirmDialog.show();
    This seems to work but doesnt add the data i input into the database.

Maybe you are looking for