Q. I am using hector (cassandra client) and storing UTF8 type values in columns, on the client side I am using hector's StringSerializer to serialize/ deserialize values. It works fine for normal strings (only alphanumeric chars)…but when there are non-alphanumeric chars (like —> , ; / ) it serializes it ..but is unable to deserialize..anyone else has seen this issue ?
Related
Following is what I am doing.
I am using mule MS-Dynamics connector to create a contact
I get records from mysql Database (Inserted from source file)
Transform it to CRM specific object in dataweave
This works for over 10 Million records. But for a few hundred records
I am getting the following error:
Problem writing SAAJ model to stream: Invalid white space character (0x1f) in text to output (in xml 1.1, could output as a character entity)
With some research I found out that (0x1f) represents US "Unit separator".
I tried replacing this character in my dataweave like this
%var replaceSaaj = (x) -> (x replace /\"0x1f"/ with "" default "")
but the issue persists.
I even tried to look for these characters in my source file and database with no luck.
I am aware that this connector internally uses SOAP services.
I have a SP that contain 3 input parameters and 4 outputs. inputs are NUMBER, the outputs one is a VARCHAR(descResponse) and the others are NUMBER.
In java, when I log the response:
logger.info("Out["+res.getCodResponse()+"]["+res.getDescResponse()+"]");
the print is:
Out[-1861][ORA-01861: literal does not match format string]
The map between java attributes with the SP parameters are the same type (number : Integer/Double, varchar: String).
the problem is when i use sql developer with the same parameters the response is ok. So i don't know if my WS is not working or the SP.
I hava distinct NLS settings on my sql devoloper than my DB so I change the NLS settings on my sql devoloper and i could detect the wrong date reference and fix it.
I have to find a user-defined String in a Document (using Java), which is stored in a database in a BLOB. When I search a String with special characters ("Umlaute", äöü etc.), it failes, meaning it does not return any positions at all. And I am not allowed to convert the document's content into UTF-8 (which would have fixed this problem but raised a new, even bigger one).
Some additional information:
The document's content is returned as String in "ISO-8859-1" (Latin1).
Here is an example, what a String could look like:
Die Erkenntnis, daà der Künstler Schutz braucht, ...
This is how it should look like:
Die Erkenntnis, daß der Künstler Schutz braucht, ...
If I am searching for Künstler it would fail to find it, because it looks for ü but only finds ü.
Is it possible to convert Künstler into Künstler so I can search for the wrong encoded version instead?
Note:
We are using the Hibernate Framework for Database access. The original Getter for the Document's Content returns a byte[]. The String is than returned by calling
new String(getContent(), "ISO-8859-1")
The problem here is, that I cannot change this to UTF-8, because it would then mess up the rest of our application which is based on a third party application that delivers data this way.
Okay, looks like I've found a way to mess up the encoding on purpose.
new String("Künstler".getBytes("UTF-8"), "ISO-8859-1")
By getting the Bytes of the String Künstler in UTF-8 and then creating a new String, telling Java that this is Latin1, it converts to Künstler. It's a hell of a hack but seems to work well.
Already answered by yourself.
An altoghether different approach:
If you can search the blob, you could search using
"SELECT .. FROM ... WHERE"
+ " ... LIKE '%" + key.replaceAll("\\P{Ascii}+", "%") + "%'"
This replaces non-ASCII sequences by the % wildcard: UTF-8 multibyte sequences are non-ASCII by design.
I am developing a web application using JSP & Servlet (IDE: Eclipse, Database: Oracle10). I am using jqGrid to display records in tabular format.
I am using datatype: "xml" for jqgrid.
I have a field in database for storing address and that field contains special characters like , ; & etc. If any of the Address from database contains & then jqgrid is giving me message response 200 ok, type: parsererror and no data is shown in the grid , and if i remove the & from the database then it is not showing me this message and showing the data in grid.
{name:'ADDRESS',index:'ADDRESS', width:80,sortable:true,editable:true}
so my question is that how should I send the data, which contains &
Update1:
I know that some characters are XML reserved characters like & < and >, but then in that case i have to write loop for checking address on server side and if that address contains this reserved characters then i have to write them as hexadecimal, so is there any better way for doing this?
Update2:
I am using Servlets.
following is my code snippet.
out.print("<cell>" +ADDRESS +"A&BC"+"</cell>");//will show parsererror
out.print("<cell>" +ADDRESS +"A"+"</cell>");//will not show error, and data is diplayed
Thanks in advance...
To place information having XML reserved characters you have to use XML reserved characters <![CDATA[...]]> (see here and here for example) construct to produce correct XML data.
On the client side you should additionally use autoencode: true jqGrid option additionally.
I am trying to figure out how to generate a matching MD 5 hash value between SQL Server and ColdFusion. The root cause appears to be that the SQL Server field is an nvarchar datatype, which seems to mean I need to do something with the encoding of the string I would hash in ColdFusion or Java to make it match, but I am unable to figure it out. To be clear if this was a SQL Server varchar field, everything works.
Here's the code I'm trying:
<cfset stringToHash = "Hello world!">
<cfquery name="sqlserver" datasource="#mySqlServerDSN#">
SELECT RIGHT(
master.dbo.fn_varbintohexstr(
HashBytes(
'MD5',
CAST(<cfqueryparam value="#stringToHash#" cfsqltype="cf_sql_varchar"> AS nvarchar(max))
)
)
, 32) AS HASHED
</cfquery>
<cfoutput>
<pre>
CF UFT-8: #hash(stringToHash, 'MD5', 'UTF-8')#
CF UFT-16: #hash(stringToHash, 'MD5', 'UTF-16')#
SQL Server: #sqlserver.hashed#
</pre>
</cfoutput>
Produces
CF UTF-8: 86FB269D190D2C85F6E0468CECA42A20
CF UTF-16: 0C89A9720D83539E3723BB99C07D069F
SQL Server: f9a6119c6ec37ce652960382f8b59f2c
So I'm guessing I need to change the final argument I'm passing to hash() to be a different encoding, but I can't figure it out. I've also tagged this question as Java too, because I'm more than happy to take an answer in that language as well.
By default SQL Server uses the UTF-16 in little-endian byte order character set for nvarchar fields.
In ColdFusion you must use the 'UTF-16LE' character set.
<cfscript>
helloWorld = "Hello, World!";
utf8HashCF = lcase(hash(helloWorld, 'MD5', 'UTF-16LE'));
</cfscript>
<cfoutput>
#utf8HashCF# <br />
</cfoutput>
I'm curious why your sql server column is nvarchar; it's not necessary for hashes. nvarchar is for storing extended character sets, which you shouldn't be getting back from a hash function.
Regardless, I tried all of the hash algorithms available in CF9 and none of them generate the hash you're looking for.
Unless you need to keep the column set to nvarchar for some reason you haven't already explained, why not change it to varchar?
I don't think it's the CF hashing because if you compare the CF to Java they create the same hash. Both the CF & Java output "65a8e27d8879283831b664bd8b7f0ad4" on my box and it matched the SQL hash when I changed the cast to varchar(32).
In the past when I've needed to do any sort of hash creation and comparison, I created a service that returns a string so you don't have to worry about cross platform algorithm issues. You could also just have sql do it all for you, but then you have the business logic in the wrong layers but to each their own.
<cfscript>
helloWorld = "Hello, World!";
javaString = CreateObject( "java", "java.lang.String" ).Init(helloWorld);
javaHash = CreateObject( "java", "java.security.MessageDigest" ).getInstance("MD5");
javaHash.reset();
javaHash.update(javaString.getBytes("UTF-8"),0,javaString.length());
javaBigInt = CreateObject( "java", "java.math.BigInteger" ).Init(1,javaHash.digest());
utf8HashCF = lcase(hash(helloWorld, 'MD5', 'UTF-8'));
utf8HashJava = variables.javaBigInt.toString(16);
</cfscript>
<cfoutput>
#utf8HashCF# <br />
#utf8HashJava#
</cfoutput>