Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 23-09-2009
Member
 
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.
Reply With Quote
  #2  
Old 23-09-2009
Member
 
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.
Reply With Quote
  #3  
Old 23-09-2009
Member
 
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.
Reply With Quote
  #4  
Old 23-09-2009
Member
 
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.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to store byte array to database with JDBC?"
Thread Thread Starter Forum Replies Last Post
Store content of file in array of bytes Aaliya Seth Software Development 5 21-01-2010 01:25 PM
File byte array to save in database New ID Software Development 5 21-01-2010 11:22 AM
How to store space in a array in a C program NetworkeR Software Development 3 03-11-2009 12:41 PM
Fill an array using a mysql database Jacek Software Development 3 16-04-2009 12:12 AM
How JSP call JDBC database connection Swetlano Software Development 3 28-02-2009 01:46 PM


All times are GMT +5.5. The time now is 08:08 PM.