• Portada
    • Recientes
    • Usuarios
    • Registrarse
    • Conectarse
    1. Foro
    2. Niubi
    3. Mensajes
    N
    • Perfil
    • Siguiendo 0
    • Seguidores 0
    • Temas 0
    • Mensajes 2
    • Mejor valorados 0
    • Controversial 0
    • Grupos 0

    Publicados por Niubi

    • RE: Problema con Java y mediumblob obtenido de MySQL

      @Istarion:

      Y mas facil:
      Sh*tmores: Convert java.sql.Blob to String

      ;D

      Oztia! ke weno, jijiji

      pues bueno dejaré el código como sería…

                      byte[] bdata;
           		int id=0;
           		String comen1=new String();
           		String st1 =new String();
           		Blob st2=null;
           		String text=new String();
      
                  while (rs1.next())
                  {            	
                  	stmt = pConexion2.prepareStatement
                      ("INSERT INTO comentarios_ontologia VALUES (?,?,?)");
      
                  	//VAMOS OBTENIENDO LOS DATOS DE LAS COLUMNAS DE LA TABLA JENA_LONG_LIT
                  	id=(Integer)rs1.getObject(1);
                  	comen1=(String)rs1.getObject(2);
                  	st1=tc.TratarString(comen1);
                  	st2=rs1.getBlob(4);    
      
                  	bdata = st2.getBytes(1, (int) st2.length());
                  	text = new String(bdata);
                  	bdata=st1.concat(text).getBytes();
      
                  	stmt.setInt(1,id);
                  	stmt.setBytes(3, bdata); //En vez de utilzar el metodo setBlob, utilizamos este
      
                  	stmt.executeUpdate();
                  }
      

      Saludos!

      publicado en Software
      N
      Niubi
    • Problema con Java y mediumblob obtenido de MySQL

      Hola

      Estoy un poco desesperado con el problema que me ocurre, no se como concatenar un mediumblob y un varchar (8tring) desde java…

      Obtengo un varchar de una tabla de una base de datos y desde java lo trato como String, es decir, tengo el siguiente campo:

      campo1 –> varchar (100)
      campo1='Lv:0:39:http://www.w3.org/2001/XMLSchema#stringIf the author of an article is a person, then there: '

      Y lo que hago en java es tratarlo, dejandolo asi en un variable:
      String str1=If the author of an article is a person, then there

      Por otra parte tengo otro campo de la misma tabla que antes, pero de diferente tipo (mediumblob),

      campo2 –>mediumblob
      campo2='exists an editor, who is either this author or the editor responsible for this author. The section that contains this article is one of the sections managed by this editor.'

      ¿Que quiero? Pues quiero concatenar este campo2 a la variable str1 que tengo en mi programa java.

      Insertando el resultado en el campo x de otra tabla como mediumblob el siguiente valor:

      If the author of an article is a person, then there exists an editor, who is either this author or the editor responsible for this author. The section that contains this article is one of the sections managed by this editor.

      He intentado hacerlo, pero finalmente se me ha quedado el siguiente código (lo dejo por si acaso no anda mal encaminado)

      while (rs1.next())
                  {
                  	stmt = conexion2.prepareStatement
                      ("INSERT INTO comentarios VALUES (?,?)");
      
                  	//VAMOS OBTENIENDO LOS DATOS DE LAS COLUMNAS DE LA TABLA JENA_LONG_LIT
                  	int id=(Integer)rs1.getObject(1);
                  	String comentario1=(String)rs1.getObject(2);
                  	String st1=tc.TratarString(comentario1);
      
                  	Blob st2=rs1.getBlob(4);           	
      
                  	stmt.setInt(1,id);
                  	stmt.setString(2,st1.concat(st2));//Aquí es donde me pierdo porque no los puedo concatenar
      
                  	int retorno=stmt.executeUpdate();
                  }
      
      

      Espero que me haya explicado bien y que alguien me pueda echar una mano (si de la forma que había pensado en hacer está mal, decidme alguna alternativa)

      Muchas gracias delantadas.

      Saludos!

      publicado en Software
      N
      Niubi
    • 1 / 1