Results 1 to 4 of 4

Thread: How to store byte array to database with JDBC?

  1. #1
    Join Date
    Apr 2009
    Posts
    55

    How to store byte array to database with JDBC?

    I am trying this method to add database content through the JDBC, But having lot of trouble in this process but Can anyone tell me whether storing a data through the byte array to the database with JDBC is possible.

  2. #2
    Join Date
    Apr 2008
    Posts
    193

    Re: How to store byte array to database with JDBC?

    You need to use a PreparedStatement rather than a regular statement since Java and SQL won't let you write out a list of bytes. To access an Oracle Lite database, your Java program must first load the Oracle Lite JDBC driver and then establish a connection to the database. Compared to Spring JDBC, iBatis is a higher level of abstraction that handles more work for you without placing any restrictions on what you can do.

  3. #3
    Join Date
    Feb 2008
    Posts
    121

    Re: How to store byte array to database with JDBC?

    I can build the ImageIcon before it goes to the database and i can successfully write the image to a file from Access using a FIleOutputStream, to confirm it is stored correctly. The Class.forName method finds, loads, and links the referenced Oracle Lite JDBC driver class. You do not need to explicitly create an instance of the POLJDBCDriver class. An instance of the POLJDBCDriver class is automatically created and registered with the JDBC driver manager when you call Class.forName.

  4. #4
    Join Date
    Jan 2009
    Posts
    150

    Re: How to store byte array to database with JDBC?

    Using straight JDBC (or presumably Spring JDBC), I can get an InputStream on the file and tell a PreparedStatement object to use the stream as a bind variable. To call a stored procedure using the executeQuery method, first create a Statement object, which you assign the value returned by the createStatement method of the current connection object. iBatis doesn't seem to know how to deal with InputStreams as parameters.

Similar Threads

  1. Store content of file in array of bytes
    By Aaliya Seth in forum Software Development
    Replies: 5
    Last Post: 21-01-2010, 01:25 PM
  2. File byte array to save in database
    By New ID in forum Software Development
    Replies: 5
    Last Post: 21-01-2010, 11:22 AM
  3. How to store space in a array in a C program
    By NetworkeR in forum Software Development
    Replies: 3
    Last Post: 03-11-2009, 12:41 PM
  4. Fill an array using a mysql database
    By Jacek in forum Software Development
    Replies: 3
    Last Post: 16-04-2009, 12:12 AM
  5. How JSP call JDBC database connection
    By Swetlano in forum Software Development
    Replies: 3
    Last Post: 28-02-2009, 01:46 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,263,334.79406 seconds with 16 queries