I am connecting to a MySQL database but I got an error about timezone. So I solved it by adding useLegacyDatetimeCode=false&serverTimezone=UTC:
String url = "jdbc:mysql://" + host + ":" + port + "/" + db_isim +
"?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC";
Now I need to add this too: ?useUnicode=true&characterEncoding=utf8
Is there a way for this?
(Not very good at English so basic explanation or just the code will be good)
I need to add this code for Turkish characters. I tried adding next to it but the connection went lost.
You can type the code in the following format and if you encounter a problem in the connection make sure the variables used within the code or make sure to add jdbc library
String url = "jdbc:mysql://" + host + ":" + port + "/" + db_isim + "?useUnicode=true&useJDBCCompliantTimezoneShift=true&characterEncoding=utf8&useLegacyDatetimeCode=false&serverTimezone=UTC";
Have you tried :
String url = "jdbc:mysql://" + host + ":" + port + "/" + db_isim
+ "?useUnicode=true&"
+ "useJDBCCompliantTimezoneShift=true&"
+ "useLegacyDatetimeCode=false&"
+ "serverTimezone=UTC&"
+ "characterEncoding=utf8";
Related
I don't get it why it says it cannot find symbol append.
do i need to use Stringbuffer? i got this code on a tutorial for receipts from youtube, and the uploader disabled comments so I can't ask him directly. please help me. Im still an amateur at java.
Tell me if I need to post my whole code or what code would you want to see to see errors. thanks in adv.
Calendar timer = Calendar.getInstance();
timer.getTime();
SimpleDateFormat tTime = new SimpleDateFormat("HH:mm:ss");
tTime.format(timer.getTime());
SimpleDateFormat Tdate = new SimpleDateFormat("dd-MMM-yyyy");
Tdate.format(timer.getTime());
jtxtReceipt.append("\ Water Station Receipt:\n" +
"Reference:\t\t\t" + refs +
"\n=========================================\n" +
"Mineral:\t\t\t" + jtxtMineral.getText() + "\n\n" +
"Purified:\t\t\t" + jtxtPurified.getText() + "\n\n" +
"Travel:\t\t\t" + jtxtTravel.getText() + "\n\n" +
"VAT:\t\t\t" + jtxtVat.getText() + "\n"+
"\n========================================\n" + "\n" +
"Tax:\t\t\t" + jtxtTax2.getText() + "\n" +
"Subtotal:\t\t\t" + jtxtSubTotal.getText() + "\n" +
"Total:\t\t\t" + jtxtTotal.getText() + "\n" +
"===========================================" +
"\nDate:" + Tdate.format(timer.getTime()) +
"\ntTime:" + tTime.format(timer.getTime()) +
"\n\t\tThank you ");
The append method doesn't exist in the String class. You can either user a StringBuilder to do the job, or if it's a light concatenation, just use the + operator
The append method doesn't work on TextField Palette. So, if You're on TextField Palette, replacing that with TextArea Palette should solve the problem.
I have a java virtual user script that is sending a payload request. I am trying to use values from a file to send via a loadrunner file parameter.
here is the payload:
private static final String PAYLOAD =
"<ips_cad_mdt>\n" +
" <SignOnRequest>\n" +
" <DestApplication>hhhh</DestApplication>\n" +
" <OrigApplication>hhh</OrigApplication>\n" +
" <SessionRef>3</SessionRef>\n" +
" <Aliasing>1234</Aliasing>\n" +
" </SignOnRequest>\n" +
"</ips_cad_mdt>";
I would like to use something like the following:
private static final String PAYLOAD =
"<ips_cad_mdt>\n" +
" <SignOnRequest>\n" +
" <DestApplication>hhh</DestApplication>\n" +
" <OrigApplication>hhh</OrigApplication>\n" +
" <SessionRef>3</SessionRef>\n" +
" <Aliasing>”+lr.eval_string(“{AliasId}”)+”</Aliasing>\n" +
" </SignOnRequest>\n" +
"</ips_cad_mdt>";
for some reason i cant see any output for this value. do i need to declare a variable: e.g. lr.save_string("AliasId", "{AliasId}");
an example of this would help loads. Many Thanks
There seems to be an error in the code completion in VuGen. The parameters should be reversed and without the {} in save_string.
lr.save_string("1234","myId");
lr.message(lr.eval_string("{myId}"));
In the documentation it is correct - https://admhelp.microfocus.com/lr/en/12.55/help/function_reference/FuncRef.htm#FuncRef/c_vuser/lrFr_lr_save_string.htm?Highlight=lr_save_string
I asked the responsible team to fix the code completion in VuGen so you will be able to see this change in one of the future releases.
I am relatively new to SOAP and wanted to write a SOAP client in JAVA. I figured out that the WSDL has a lot of other crap and as I use just one service out of it, hence SAAJ would be the shortest way. The first WSDL I got was RPC encoded and did not support SSL connections (http link). The call I made was this:
String request = "<soapenv:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:urn=\"urn:AxessInterface\">"
+ " <soapenv:Header/>"
+ " <soapenv:Body>"
+ " <urn:getModemFromACS soapenv:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">"
+ "<ModemIDMACAddressChoice xsi:type=\"urn:ModemIDMACAddressChoiceStruct\">"
+ " <ModemID xsi:type=\"xsd:string\">"
+ modemId
+ "</ModemID>"
+ " </ModemIDMACAddressChoice>"
+ " </urn:getModemFromACS>"
+ " </soapenv:Body>"
+ "</soapenv:Envelope>";
The new WSDL that I have is I guess NOT RPC encoded (it does not have that "style=rpc" tag anywhere) and the link is SSL enabled (https with one way authentication). The style is "document" in this WSDL.
I have a couple of issues:
My soap call doesnt work. I modified it to be:
String request = "http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:urn=\"urn:AxessInterface\">"
+ " "
+ " "
+ " "
+ " "
+ " "
+ modemId
+ ""
+ " "
+ " "
+ " "
+ "";
I am not sure why the code cannot be displayed, i removed the line "soapenv:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" . With this i get a SOAPFault with message: "list index out of range"
Can someone tell me how to add that truststore to my SOAP client? (I use System.setProperty but I am not sure if this is the best way to go).
How can I put each line of the host in the message body? I work with a JTextArea.
String host = InetAddress.getLocalHost().getHostName().toString();
texto_recepcion.setText(host + texto_recepcion.getText() + dpRecepcion.getAddress() + " " + mensaje_recibido + "\n");
How it is now:
I resolve my question with append function.
String host = InetAddress.getLocalHost().getHostName().toString();
texto_recepcion.append(host); // ***Use the function append for solve the problem***
texto_recepcion.setText(texto_recepcion.getText() + dpRecepcion.getAddress() + " " + mensaje_recibido + "\n");
Thanks a lot
Why don't you add the newline character "\n" to the beginning of the string?
texto_recepcion.setText("\n" + host + texto_recepcion.getText() + dpRecepcion.getAddress() + " " + mensaje_recibido);
In the browser (IE and Firefox) if you have a relative link and your URL is: http://domain/somepath/lastfolder/
the relative link becomes:
http://domain/somepath/lastfolder/linkdocname.html
if the URL is http://domain/somepath/lastdoc the relative link becomes:
http://domain/somepath/linkdocname.html
http://domain/somepath/lastfolder/ becomes:
http://domain/somepath/lastfolder/linkdocname.html
Is there a way to replicate this using JSP without writing a special function?
I tried to get the base URL using:
baseURL = request.getScheme() + "://" + request.getServerName() + ":"
+ request.getServerPort()+ request.getRequestURI();
but that gets me the whole path of the requst URI and doesn't drop off the last bit if it doesn't end in a "/" Then if I try:
baseURL = request.getScheme() + "://" + request.getServerName() + ":"
+ request.getServerPort() + request.getContextPath();
that gives me everything up to the web container folder but not any of the folders after that.
In your last string building attempt you are missing a port number, even though you specified ":"
Try this:
new URL(request.getScheme(), request.getServerName(),
request.getServerPort(), request.getContextPath());
You can also build the string yourself and remove default ports if needed:
public String getBaseUrl(HttpServletRequest request) {
if (( request.getServerPort() == 80 ) || ( request.getServerPort() == 443 )) {
return request.getScheme() + "://" + request.getServerName() +
request.getContextPath();
} else {
return request.getScheme() + "://" + request.getServerName() + ":" +
request.getServerPort() + request.getContextPath();
}
}