£ symbol creating issue when converting dataset to memory steam - byte

String="
skdhfgd&~!##$%^&*()£
"
MemoryStream stream = new MemoryStream(Encoding.Default.GetBytes(xml));
error:ReadTimeout = 'stream.ReadTimeout' threw an exception of type 'System.InvalidOperationException'

Related

msxml6.dll error '800c0005' The system cannot locate the resource specified [duplicate]

I have a function which uses MSXML to post an XML document which yesterday started failing despite no change being made to the code. The function is as follows:
Public Function PostFile(ByVal address As String, ByVal data As Byte()) As xmldocument
Dim xmlHTTP As New MSXML2.XMLHTTP
Dim response As New XmlDocument
Dim xmlDoc As New MSXML2.DOMDocument
Try
xmlDoc.load(data)
xmlHTTP.open("post", address, False)
xmlHTTP.send(xmlDoc)
If xmlHTTP.responseXML.xml <> String.Empty Then
response.LoadXml(xmlHTTP.responseXML.xml)
Return response
Else
Dim result As String = "<NO_Response><Error>the post succeeded to " + address + " but there was no responce returned</Error><Hint>Check FireWall Settings</Hint></NO_Response>"
response.loadxml(result)
Return response
End If
Catch ex As Exception
'Error logging code removed
End Try
Return Nothing
End Function
The XML document and the address being passed in are both correct - the line which causes the error is xmlHTTP.send(xmlDoc). I have tried this on 2 different machines with the same error each time and have also tried resinstalling MSXML3, with no success.
The exception thrown is:
InnerException: Nothing
Message: "The system cannot locate the resource specified. "
Source: "msxml3.dll"
StackTrace: " at MSXML2.XMLHTTPClass.send(Object varBody) at comms.HTTPHandler.PostFile(String address, Byte[] data) in D:\SCC\Main\Sender\Http.vb:line 42"
It turned out to be a networking issue - I didn't suspect this at first as the error was raised so quickly which didn't suggest an issue with the endpoint. The problem was with a rule which had been added (don't ask why) to the firewall preventing communication with the destination address.
If you are just processing the xml or dtd is offline, you can use:
xmlDoc.resolveExternals = False

SQLGrammar Exception in integration tests on H2 Database

#Query(nativeQuery = true, value = "SELECT *\n" +
"FROM TDED_VISITS v \n" +
"WHERE v.v_collected_data.assigneeId = ?")
List<Visit> findAllByAssigneeId(String assigneeId);
The above code is used in the repository, the purpose of the query is to return all "visits" that have a matching value with the value provided. This value is a single value from inside a JSON object in a CLOB in an oracle database such as below.
{"visitId" : 1, "assigneeId" : "agr512"}
The model is made with the associated field as below.
#Column(name = "V_COLLECTED_DATA")
#Lob
private String visitJsonString;
The errors in the logs are as below
Column "V.V_COLLECTED_DATA.ASSIGNEEID" not found; SQL statement:
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.dao.InvalidDataAccessResourceUsageException: could not prepare statement; SQL [SELECT *
FROM TDED_VISITS v
WHERE v.v_collected_data.assigneeId = ?]; nested exception is org.hibernate.exception.SQLGrammarException: could not prepare statement
Have also tried the below SQL query but given the error that the function JSON_VALUE was not found.
#Query(nativeQuery = true, value = "SELECT *\n" +
"FROM TDED_VISITS v \n" +
"WHERE JSON_VALUE(V_COLLECTED_DATA, '$.assigneeId') = ?")
Caused by: org.springframework.orm.jpa.JpaSystemException: could not prepare statement; nested exception is org.hibernate.exception.GenericJDBCException: could not prepare statement
Have spent a few days looking for similar problems for other people, but to no avail. Appreciate if anyone can help, thanks!
H2 does not support accessing JSON attributes. See here for a list of supported functions: https://www.h2database.com/html/functions.html

Linq to entities giving error when generic repository is used with List<T> object

In my ASP.NET Web API project, I am trying to use the generic repositories with the List objects under one of the methods. But it is throwing exception
Exception thrown: 'System.Data.SqlClient.SqlException' in System.Data.dll
System.Data.Entity.Core.EntityCommandExecutionException: Calling 'Read' when the data reader is closed is not a valid operation. --->
System.Data.SqlClient.SqlException: Execution Timeout Expired. The
timeout period elapsed prior to completion of the operation or the
server is not responding. ---> System.ComponentModel.Win32Exception:
The wait operation timed out
lstFinalResult object contains few rows. partnerRepo is a generic repo and will have data at the later stage, i suppose.
Please advise, where am i making the mistake. Can we mix the List with generic repository objects in the linq query ?
Here is the linq code :-
List<UserDocumentResult> lstFinalResult = new List<UserDocumentResult>();
foreach (DocumentMapping dm in lstMappings)
{
lstFinalResult.Add(new UserDocumentResult { PID = dm.PartnerID,
DocMappingID = dm.DocumentMappingID,
EntityType = "",
Name = ""
});
}
var partnerRepo = _docRepository.PtGenericRepo.Get();
var entityCodesRepo = _docRepository.EntityCodeGenericRepo.Get();
---While debugging, I am getting error in the below code only.
var qualifiedPartnerSet = (from tmp in lstFinalResult
join px in partnerRepo on tmp.PID equals px.PartnerID
join ecx in entityCodesRepo on px.EntityCodeID equals ecx.EntityCodeID
select new UserDocumentResult
{
PID = px.PartnerID,
MappingID = tmp.MappingID,
EntityType = ecx.DisLabel.Trim(),
Name = px.NameLine1.Trim() + px.NameLine2.Trim(),
}).ToList();

Trying to make a search bar to a data grid view and getting a SQLException

I'm trying to create a form with a data grid view, a combo box with columns, and a text box search bar. I've found lots of YouTube videos on line (https://www.youtube.com/watch?v=KaQs1K63Q-o&list=PL4Io1EUy0d2zUOyEiVt-GwI6WzqdEgVbZ&index=15) and I keep getting an exception error. I've tried to look on the manuals, stack overflow forums, videos, and other sources for days and still coming up dry. I am very new to C# and programming SQL to C# so I think its something simple that I'm just not seeing. When I look closer in the exception detail it says that there is an error being returned by SQL Server. I've tried hitting it at all angles but nothing gets fixed.
SqlConnection con = new SqlConnection("Data Source = LAPTOP - 2H9706D7\\THIBEAUX; Initial Catalog = MetroTest; Integrated Security = True");
This is the connection but this part is "2H97067\THIBEAUX; I put an extra "\" to get rid of the escape sequence error.
private void textBox1_TextChanged(object sender, EventArgs e)
{
if (comboBox1.Text == "ID")
{
SqlDataAdapter sda = new SqlDataAdapter("Select * from [Program Tools] where ID like '%" + textBox1.Text + "%'", con);
DataTable data = new DataTable();
sda.Fill(data);//right here the exception is being thrown
ToolDataGrid.DataSource = data;
}
}
An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll
Additional information: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
can anyone help me out with this?
And yes I know I shouldn't have put spaces between my Tables names I'm working on renaming them later.

Tika text extraction not working on HDFS

I'm trying to use Tika to extract text from a bunch of simple txt files stored on HDFS. I have the following code in my reducer, but surprisingly Tika does not return anything. It work fine in my local machine but as soon as I move everything to hadoop cluster, the result is empty.
FileSystem fs = FileSystem.get(new Configuration());
Path pt = new Path(Configs.BLOBSTORAGEPREFIX+fileAdd);
InputStream stream = fs.open(pt);
AutoDetectParser parser = new AutoDetectParser();
BodyContentHandler handler = new BodyContentHandler();
Metadata metadata = new Metadata();
parser.parse(stream, handler, metadata);
spaceContentBuffer.append(handler.toString());
The last line append the extreaxted content to a StringBuilder, but it is always empty.
p.s. my hadoop cluster is Azure HDInsight so the HDFS is Blob Storage.
I also tried the following code
Metadata metadata = new Metadata();
BodyContentHandler handler = new BodyContentHandler();
Parser parser = new TXTParser();
ParseContext con = new ParseContext();
parser.parse(stream, handler, metadata, con);
and I got the following error message:
Failed to detect the character encoding of a document
If the user does not specify Content-Type when uploading a blob, it will be set to “application/octet-stream” by default.

Resources