Ver Mensaje Individual
  #2  
Antiguo 07-04-2004
santana santana is offline
No confirmado
 
Registrado: nov 2003
Posts: 1.030
Reputación: 0
santana cantidad desconocida en este momento
Hola.

Normalmente lo que se hace es pasar la imagen a binario y entonces se inserta en la base de datos. Investiga a partir de ese punto...

No he trabajado nunca con Java / Interbase, te dejo para que te orientes una parte de código extraido del framework Dinamica creado por Martin Cordova. Te aconsejo que le eches un vistazo empezando por la guía de usuario, la verdad es que es muy interesante.



Código:
 
  	/**
  	 * Save binary file to blob column using a prepared statement.<br>
  	 * The prepared statement must contain only one dynamic parameter (?),
  	 * and it must correspond to the BLOB column. Example:<br>
  	 * insert into images (id, title, imgsize, data) values (1,'my image', 8112, ?)
  	 * <br><br>
  	 * This means that the SQL must be pre-processed by your code in order to
  	 * set the static values. GenericTransaction superclass provides the method getSql()
  	 * to help you achieve easy static SQL generation.
  	 * @param sql SQL used to build prepared statement. The blob column will
	 * be the only dynamic (?) parameter.
  	 * @param path File to be uploaded into the blob column
  	 * @throws Throwable
  	 */
 
 
	public void saveBlob(String sql, String path) throws Throwable
 	  {
   
 		  /* create buffer to read image data */
 				File f = new File( path );
 		   		FileInputStream img = new FileInputStream(f);		
 				int size = (int)f.length();
 		   		BufferedInputStream buf = new BufferedInputStream(img,16000);
   
 		  /* save image using prepared statement */
 				PreparedStatement p = null;
 			  
 				try
 				{
 	 		  	p = _conn.prepareStatement(sql);
 				   p.setBinaryStream(1, buf, size);
 				   p.execute();
 				}
 				catch (Throwable e)
 				{
 				   throw e;
 				}
 				finally
 				{
 				   if (p!=null) p.close();
 				   if (img!=null) img.close();
 				   if (buf!=null) buf.close();
 				}
   
 	}
Un saludo.
Responder Con Cita