just as in the title I have this error every time I launch my request, do you have the solution? it seems to me that this is a problem of apostrophe
stm.executeUpdate("UPDATE client SET Nom='"+txtno.getText()+"',Prenom='"
+txtpr.getText()+"',DateArrivee='"+txtda.getText()
+"',DataFin='"+txtdad.getText()+"',chambre='"
+txtid.getSelectedItem().toString()+"',Nb_personne='"
+txtnomb.getText()+"',Categorie='"+txtca.getText()
+"' WHERE 'Prix'='" +txtpri.getText());
You don't need (') around Prix. Try without it.
If apostrophe is the issue you can try to add slashes for apostrophe in getText method of the variables.
Also 'Prix' stands out form other variables please check it as mentioned below
stm.executeUpdate("UPDATE client SET Nom='"+txtno.getText()+"',Prenom='"+txtpr.getText()+ "',DateArrivee='"+txtda.getText()+"',DataFin='"+txtdad.getText()+"',chambre='"+txtid.getSelectedItem().toString()+"',Nb_personne='"+txtnomb.getText()+ "',Categorie='"+txtca.getText()+"' WHERE Prix=" +txtpri.getText());
Related
I'm sending a request from SOAPUI to a wiremock server, and I'm attempting to match the url's.
This is the request that is being sent out: /user/test/?and=query
I've written the following regular expression:
stubFor(post(urlPathMatching("/user/test/\\?(and)\\=([a-z]*)"))
The problem is when I try to match the "?" when I use one backslash to capture the literal character, I get an error in Java saying:
"Illegal Escape Character"
What I tried to do to resolve the problem:
I know the solution is to use the second backslash to capture the "?" like this: "\?", but when I send the request I get an error saying the urls don't match because this is the request that is matched against the original one being sent from soap ui:
/user/test/\?(and)\=([a-z]*)
Can someone please help me on this?
EDIT: Second attempt
I've tried to use the dot notation to represent the "?" and "=" symbol. I've tested this on a regular expression tester and it checks out, but, It's still saying the url's dont match on soap ui.
Regular expression: stubFor(post(urlPathMatching("/user/test/.*(and).*([a-z]*)")).atPriority(1)
mismatched url: /user/test/.*(and).*([a-z]*)
When you are using urlPathMatching() you shouldn't put your query parameters in the url. That approach only works for urlEqualTo().
Instead you should specify the parameters separately using withQueryParam(), so your stub setup should be:
stubFor(post(urlPathMatching("/user/test/")).withQueryParam("and", matching("[a-z]*")));
\\ is just escapse the \, you should add one more \ before ? to escapse ?.
Just like this:
stubFor(post(urlPathMatching("/user/test/\\\?(and)\\=([a-z]*)"))
I'm having a strange condition where i'm trying to type into input by using sendKeys , the reuslt is that specific chars doesn't seem to be implemented in the input at all.
What i'm trying to do:
webDriver.findElement(By.id("additionalInfo(token_autocompleteSelectInputId)")).sendKeys("(test)");
the result is that input field is now : test) and the missing char is '(' .
If i will try
webDriver.findElement(By.id("additionalInfo(token_autocompleteSelectInputId)")).sendKeys("((((((((((")
the result is that the input is empty.
Anyone ever faced this issue before? it is happening on a very specific input in the app, couldn't find anything related to it in the html code.
Thanks in advance.
Edit: I can manually type ( in the input field.
Maybe it's a special character for selenium, have you tried using escape characters? Something like backslash before it if it allows it.
Edit: I found some issue report on github from last year, not sure if they agreed to not fix it. Executing a script to type "(" seems to be an alternative.
Source: https://github.com/seleniumhq/selenium/issues/674
try declaring the key as a string first
String keyToSend = "(test)";
webDriver.findElement(By.id("additionalInfo(token_autocompleteSelectInputId)")).sendKeys(keyToSend);
In this case you should try using JavascriptExecutor as below :-
WebElement el = webDriver.findElement(By.id("additionalInfo(token_autocompleteSelectInputId)"));
((JavascriptExecutor)webDriver).executeScript("arguments[0].value = arguments[1]", el, "(test)");
Hope it helps..:)
I have been banging my head for this issue but to no result.
I have a URL like this :
http://1.1.1.1:8080/Offers
Then I click on a Create button. It becomes :
http://1.1.1.1:8080/newaccount/Country/Region/State/2016/11/12/offer-111111.html
The 2016/11/12/offer-111111 portion of the URL keeps changing at each run.
Any ideas how I should use a regular expression from newaccount/Country/Region/State/2016/11/12/offer-111111, so that I could use this after 1.1.1.1:8080/, which would mean it would run irrespective of the changes in the URL?
As per your description:-
You are getting the second URL i.e.
http://1.1.1.1:8080/newaccount/Country/Region/State/2016/11/12/offer-111111.html
as a response of first URL hit.
So you can use below mentioned Regular Expression
newaccount/Country/Region/State/(.*?).html
and after that append the reference name in place of 2016/11/12/offer-111111 like this
http://1.1.1.1:8080/newaccount/Country/Region/State/${RegEX_RefrenceName}.html
Try this:
http://1.1.1.1:8080/newaccount/Country/Region/State/\d{4}/\d\d/\d\d/offer-\d+.html
I'm trying to add a jQuery post to some JavaScript on a web page. The entire page is built up of several Velocity templates. Everything has been fine until I've tried to add the jQuery post, now I get:
org.apache.velocity.exception.ParseErrorException: Encountered "," at line 282, column 24 of /WEB-INF/velocity/www/comments.vm
Was expecting one of:
"(" ...
<RPAREN> ...
<ESCAPE_DIRECTIVE> ...
~~~snip~~~
Line 282 is $.post(... and column 24 appears to be the first "," character. Initially I had the JSON on this line, but I moved it up (to the var myJSONObject ... line)as I thought the error related to invalid JSON (tabs at the start of the line gave a misleading column number).
var myJSONObject = {"body": "", "action": "postcomment", "submitted": "true", "ajax": "true"};
myJSONObject.body = $("body").val();
$.post("$!{articleurl}", myJSONObject, function(result){
btn.textContent='Comment sent successfully.';
});
Minor Update
I changed the following lines:
var url = "$articleurl";
$.post(url, myJSONObject, function(result){
~~~snip~~~
The parse exception still focuses on the first ",". I'm assuming the issue is that Velocity thinks it should be able to resolve $.post - when in fact, it's jQuery. I've used jQuery in other Velocity VM templates without any problem. Is there a way to get Velocity to ignore certain lines / statements when parsing?
Update 2
I found this link about escaping references in Velocity, but it does not resolve my issue. Adding a "\" before $.post gives me the exact same error, but the column is one extra, because of the character added at the start of the line.
You can wrap your javascript with #[[ ... ]]# which tells Velocity to not parse the enclosed block (new in Velocity 1.7)
#[[
<script>
...
</script>
]]#
Ok, there appears to be two solutions for this:
First, with jQuery we can just avoid using the global alias $ and instead use the jQuery object directly:
jQuery.post(url, myJSONObject, function(result){
~~~snip~~~
In my case, the above works great. But I suspect in other scenarios (non-jQuery) this may not be possible. In which case, we can 'hide' our character within a valid Velocity reference like this:
#set( $D = '$' )
${D}
Source: http://velocity.apache.org/engine/devel/user-guide.html#escapinginvalidvtlreferences
I'd still like to know why the backslash escape didn't work, but the above will at least get me moving again. :)
I think this is a bug in version 1.6.x, because it works fine in 1.7(If it did not, please tell me, I test it many times..), according to the reference, the $ takes effect only when it is followed by a-zA-Z. I want to try do debug what happened really, but the translation code is generated by Java CC tool, it is too hard to recognize the logic...
you must create a js file with your javascript code
and import your js file into your vm code
I couldn't get it to work with any of the other fixes like escaping "$" in velocity unfortunately. I got it working by loading an external js-file with the jQuery instead of writing jQuery directly in velocity. Worked out for me at least, hope it helps someone :)
/björn
I have this string: "\"Blah \'Blah\' Blah\"". There is another string inside it. How do I convert that into: Blah 'Blah' Blah? (you see, unescaping the string.) This is because I get a SQL Where query:
WHERE blah="Blah \'Blah\' Blah"
When I parse this, I get the string above (still inside quotes and escaped.) How would I extract that, un-escaping the string? Or is ther some much easier way to do this? Thanks,
Isaac
DO NOT DO THIS.
Follow the proper steps for parametrization of a query on your Database/Platform, and you won't have to escape anything. You also will protect yourself from injection vulnerabilities.
Put the string in a property file, Java supports XML property files and the quote character does not need to be escaped in XML.
Use loadFromXML(InputStream in) method of the Properties class.
You can then use the MessageFormat class to interpolate values into the String if needed.
This should be about right. This assumes that if it starts with a quote, it ends with a quote.
if (val.startsWith("\"") || val.startsWith("\'"))
val = val.substring(1, val.length-2);
You may wish to add val = val.trim(); as well.
"\"Blah \'Blah\' Blah\"".replaceAll("\"", "")