<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic [resolved] Read sql server blob field with text inside in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/resolved-Read-sql-server-blob-field-with-text-inside/m-p/2328340#M97630</link>
    <description>Hi,
&lt;BR /&gt;I need to extract a blob field in sql server 2005 table. I put first my request in a query with tMSSqlInput like :
&lt;BR /&gt;SELECT field_Id,CONVERT(varchar(8000), convert(binary(8000), memo)) as Texte 
&lt;BR /&gt;FROM SYSADM.My_Table. 
&lt;BR /&gt;It works but all caracters with accents are lost and specials caracters too (Like @, ?, Etc.....)
&lt;BR /&gt;Is there another way to do it right ?
&lt;BR /&gt;Thanks</description>
    <pubDate>Sat, 16 Nov 2024 13:55:44 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2024-11-16T13:55:44Z</dc:date>
    <item>
      <title>[resolved] Read sql server blob field with text inside</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Read-sql-server-blob-field-with-text-inside/m-p/2328340#M97630</link>
      <description>Hi,
&lt;BR /&gt;I need to extract a blob field in sql server 2005 table. I put first my request in a query with tMSSqlInput like :
&lt;BR /&gt;SELECT field_Id,CONVERT(varchar(8000), convert(binary(8000), memo)) as Texte 
&lt;BR /&gt;FROM SYSADM.My_Table. 
&lt;BR /&gt;It works but all caracters with accents are lost and specials caracters too (Like @, ?, Etc.....)
&lt;BR /&gt;Is there another way to do it right ?
&lt;BR /&gt;Thanks</description>
      <pubDate>Sat, 16 Nov 2024 13:55:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Read-sql-server-blob-field-with-text-inside/m-p/2328340#M97630</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-11-16T13:55:44Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Read sql server blob field with text inside</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Read-sql-server-blob-field-with-text-inside/m-p/2328341#M97631</link>
      <description>Hello 
&lt;BR /&gt;
&lt;BLOCKQUOTE&gt;
 &lt;TABLE border="1"&gt;
  &lt;TBODY&gt;
   &lt;TR&gt;
    &lt;TD&gt;Is there another way to do it right ?&lt;/TD&gt;
   &lt;/TR&gt;
  &lt;/TBODY&gt;
 &lt;/TABLE&gt;
&lt;/BLOCKQUOTE&gt;
&lt;BR /&gt;Write some java code to read blob type data. In Talend, you can write java code in a routine, then call it in a job.
&lt;BR /&gt;Bes regards
&lt;BR /&gt; shong</description>
      <pubDate>Mon, 08 Jun 2009 11:12:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Read-sql-server-blob-field-with-text-inside/m-p/2328341#M97631</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-06-08T11:12:28Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Read sql server blob field with text inside</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Read-sql-server-blob-field-with-text-inside/m-p/2328342#M97632</link>
      <description>Well: first can i still use an TSSqlInput to have my db connector. 
&lt;BR /&gt; second : with the row i put a TjavaRow or Tjava ? 
&lt;BR /&gt; 
&lt;BR /&gt;I'am not specialise in Java, i have a peace of code but i don't know if it can works with Talend possibilities 
&lt;BR /&gt; try 
&lt;BR /&gt;{ 
&lt;BR /&gt; // Ouput directory with final back-slash 
&lt;BR /&gt; var OuputDir = "C:\\Temp\\export\\"; 
&lt;BR /&gt; //SQL query to extract text document from the document management table 
&lt;BR /&gt; //fields "nrid" , "title", "memo" are mandatory 
&lt;BR /&gt; //Work only for text document 
&lt;BR /&gt; var strSQL = "SELECT nrid, title, memo " + 
&lt;BR /&gt; "FROM SYSADM.dm0 " + 
&lt;BR /&gt; "WHERE (extension IS NULL OR extension='txt') "+ 
&lt;BR /&gt; "AND title IS NOT NULL " 
&lt;BR /&gt; //Execute the query with Selligent object 
&lt;BR /&gt; var MyQryObj = CreateSelligentObject("SqlHelper", CurrentSessionID); 
&lt;BR /&gt; var MyQuery = MyQryObj.ExecuteSql(strSQL); 
&lt;BR /&gt; var MyXmlDoc = InitXml(MyQuery); 
&lt;BR /&gt; var MyRows : System.Xml.XmlNodeList = FindItem("Flds", MyXmlDoc, true); 
&lt;BR /&gt; var NbrOfRows = MyRows.Count; 
&lt;BR /&gt; for ( var i=0 ; i&amp;lt;NbrOfRows; i++) 
&lt;BR /&gt; { 
&lt;BR /&gt; //Text is enconding in binary 
&lt;BR /&gt; //this line code convert binary content in text 
&lt;BR /&gt; var objEncoding = new System.Text.UTF8Encoding(); 
&lt;BR /&gt; var strDocContent = GetItemValue("DocContent", MyRows 
&lt;I&gt;);&lt;BR /&gt; var strDocContentBytes = Convert.FromBase64String(strDocContent);&lt;BR /&gt; var strNoteContent = objEncoding.GetString(strDocContentBytes);&lt;BR /&gt; var strDocNRID = GetItemValue("DocNRID", MyRows&lt;I&gt;);&lt;BR /&gt; var strDocTitle = GetItemValue("DocTitle", MyRows&lt;I&gt;);&lt;BR /&gt; var FileName = strDocNRID + "_" + strDocTitle;&lt;BR /&gt; //Write text in a file&lt;BR /&gt; var filewriter = System.IO.File.CreateText(OuputDir + FileName + ".txt");&lt;BR /&gt; filewriter.Write(strNoteContent);&lt;BR /&gt; filewriter.Close();&lt;BR /&gt; }&lt;BR /&gt;}&lt;BR /&gt;catch(e)&lt;BR /&gt;{&lt;BR /&gt; return ("&amp;lt;Error&amp;gt;" + e.description + "&amp;lt;/Error&amp;gt;");&lt;BR /&gt;}&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;</description>
      <pubDate>Mon, 08 Jun 2009 14:58:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Read-sql-server-blob-field-with-text-inside/m-p/2328342#M97632</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-06-08T14:58:53Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Read sql server blob field with text inside</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Read-sql-server-blob-field-with-text-inside/m-p/2328343#M97633</link>
      <description>Hello 
&lt;BR /&gt; 
&lt;BLOCKQUOTE&gt; 
 &lt;TABLE border="1"&gt; 
  &lt;TBODY&gt; 
   &lt;TR&gt; 
    &lt;TD&gt;Well: first can i still use an TSSqlInput to have my db connector.&lt;BR /&gt; second : with the row i put a TjavaRow or Tjava ?&lt;/TD&gt; 
   &lt;/TR&gt; 
  &lt;/TBODY&gt; 
 &lt;/TABLE&gt; 
&lt;/BLOCKQUOTE&gt; 
&lt;BR /&gt;No, write your connection in routine, do select(select field_id from tablename) on tMsSQLInput, then link to tJavaRow,eg: 
&lt;BR /&gt;assum your routine call GetBlobFile(int id), 
&lt;BR /&gt;tMsSQLInput(select field_id from tablename)--&amp;gt;tJavaRow(GetBlobFile(input_row.field_id) //read the record of blog type based on the id column. 
&lt;BR /&gt; 
&lt;PRE&gt;package routines;&lt;BR /&gt;import java.sql.*;&lt;BR /&gt;import java.io.*;&lt;BR /&gt;public class GetBlobFile {&lt;BR /&gt;	public static void readBlob(int field_id) {&lt;BR /&gt;		String driver = "net.sourceforge.jtds.jdbc.Driver";&lt;BR /&gt;		String url = "jdbc:jtds:sqlserver://192.168.0.39:1433/talend;";&lt;BR /&gt;		String user = "sa";&lt;BR /&gt;		String passwd = "Phebe.22";&lt;BR /&gt;		Connection conn = null;&lt;BR /&gt;		try {&lt;BR /&gt;			Class.forName(driver);&lt;BR /&gt;			conn = DriverManager.getConnection(url, user, passwd);&lt;BR /&gt;			PreparedStatement ps = conn&lt;BR /&gt;					.prepareStatement("select image from blob2  where id   =   ?");&lt;BR /&gt;			ps.setInt(1, field_id);&lt;BR /&gt;			ResultSet rs = ps.executeQuery();&lt;BR /&gt;			rs.next();&lt;BR /&gt;			InputStream in = rs.getBinaryStream("image"); // image is the column&lt;BR /&gt;															// name in real&lt;BR /&gt;															// table&lt;BR /&gt;			int length = in.available();&lt;BR /&gt;			FileOutputStream out = new FileOutputStream("d:/file/test/out/"&lt;BR /&gt;					+ field_id + ".png");&lt;BR /&gt;			byte[] b = new byte;&lt;BR /&gt;			int len = 0;&lt;BR /&gt;			while ((len = in.read(b)) != -1) {&lt;BR /&gt;				out.write(b, 0, len);&lt;BR /&gt;				out.flush();&lt;BR /&gt;			}&lt;BR /&gt;			out.close();&lt;BR /&gt;			in.close();&lt;BR /&gt;			rs.close();&lt;BR /&gt;			ps.close();&lt;BR /&gt;		} catch (Exception ex) {&lt;BR /&gt;			ex.printStackTrace(System.out);&lt;BR /&gt;		} finally {&lt;BR /&gt;			try {&lt;BR /&gt;				conn.close();&lt;BR /&gt;			} catch (Exception ex) {&lt;BR /&gt;			}&lt;BR /&gt;		}&lt;BR /&gt;	}&lt;BR /&gt;}&lt;/PRE&gt; 
&lt;BR /&gt;Please see my screenshots. 
&lt;BR /&gt;PS: Your peace code is not Java code. 
&lt;BR /&gt;Best regards 
&lt;BR /&gt; 
&lt;BR /&gt; shong</description>
      <pubDate>Tue, 09 Jun 2009 06:51:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Read-sql-server-blob-field-with-text-inside/m-p/2328343#M97633</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-06-09T06:51:26Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Read sql server blob field with text inside</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Read-sql-server-blob-field-with-text-inside/m-p/2328344#M97634</link>
      <description>Hi,
&lt;BR /&gt;I have a similar problem.
&lt;BR /&gt;Is there any solution to skip database connection and file creation in Java, using tJavaRow code?
&lt;BR /&gt;My BLOB column name is FileContent, which I can access with the following code:
&lt;BR /&gt;input_row.FileContent
&lt;BR /&gt;All I want to do is to convert this to String (-&amp;gt; output_row.FileContent).
&lt;BR /&gt;Components in my job:
&lt;BR /&gt;tMSSqlInput --&amp;gt; tJavaRow --&amp;gt; tXSDValidator --&amp;gt; tExtractXMLField --&amp;gt; tMap --&amp;gt; tMSSqlOutput
&lt;BR /&gt;(tXSDValidator is in Flow mode)
&lt;BR /&gt;(Temporarely FileContent datatype is varchar(max) to skip BLOB to String conversion)
&lt;BR /&gt;Thanks in advance,
&lt;BR /&gt;Gabor Varga</description>
      <pubDate>Tue, 03 May 2011 08:45:38 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Read-sql-server-blob-field-with-text-inside/m-p/2328344#M97634</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-05-03T08:45:38Z</dc:date>
    </item>
  </channel>
</rss>

