Java : Encoding windows and linux - java

I have a java class that retrieves a variable from the base and compares it with a value that is 'Transférée'.
isOK = "Transférée".equals(demande.getEtat());
When I debug the code in windows that work fine and give me true.
but when I generate the jar to run it in unix that give me false.
I change the encoding of the project to ISO-8859-**1 and **UTF-8 but the I have the same problem.
When I displayed the value of demande.getEtat() in the logs that give me Transf¿r¿e.
I used simple request JDBC for the database connection.

It was an problem of data in the database

Related

Populate DB2 parameter using Java for JDBC connection

Recently I found that during DB2 connection, we could provide the end user id which could be used in case of charge back or to track consumption of CPU by a particular id.
I found on IBM site a parameter : qwhceuid
Can someone tell me in which jar can we find this or how can I set this using Java?
This might help, for the java program to use method setDB2ClientUser to supply the value.
Another suggestion may be for the java program to set the CLIENT_USERID special register via the URL bu appending specialRegisters=CURRENT CLIENT_USERID=username;

MySQL Data Truncation Error on Certain Servers

I have done a lot of internet searches, and can't find a report of a problem quite like this one, so I'm hoping someone here might have an idea of what is going wrong. In my java code I have a query that is pulling data from the database. I have confirmed that the SQL is well-formed, and all of my other queries in this java file run fine. In fact, even this query runs as it should when I am using the dev test Tomcat server. However, when I try to run this particular query using the dev test Resin server (where it was working perfectly fine up until just recently), or the QA test server, which also uses Tomcat, I get this error:
com.mysql.jdbc.MysqlDataTruncation: Data truncation: Incorrect datetime value: '131500'
The '131500' I'm assuming is coming from the time portion of the first datetime value that is returned, which is '13:15:00'.
The particular part of this query that is causing the problem is this line:
CONCAT(DATE_FORMAT((SELECT datenotime), '%Y-%m-%d'),' ',DATE_FORMAT((SELECT appointmenttime FROM appointments WHERE appointmentdate = datenotime AND appointments.service_id = service.id), '%T'))
If I remove this then I experience no problems on any server, so it only occurs when the time is formatted and concatenated. I would think that the issue here must be some server setting? Although there were no recent changes made to the Resin server that I know of. I tried updating Resin's msyql connector jar, but that didn't help. Does anyone know what is going wrong?
Thanks!
My guess is that you are getting this error when datenotime is null.
That would make sense, since you are concatenating datenotime and then appointmenttime. If datenotime is null, then all you have left is time, which simply can't be converted to any known datetime value.

java web start app on localhost using WAMP is not able to run php scripts?

I have a signed java web start app that has been running on a server for many years. I have a need to create a version that I can run on a local machine. I have setup WAMP and the database and confirmed that these work by accessing through php scripts via localhost. My java program is also launching but there is a problem when it tries to access a local php file through locahost. Nothing is returned. I call php scripts that access the database from within the java app. Am i missing something fundamental here? ANy help appreciated. Thanks
Thanks for the responses. The problem has been solved. I forgot to turn off deprecation and other warnings so what I was getting back from the php scripts was not what I expected. Once I turned off the warnings everything functioned as expected. To sum up, I am serving up a java web start app through localhost, executing php scripts from within the java app that manipulate an sql database, and return the results to the java app.
Thanks again,
greg
Well are you using Quercus ? It would have been easier to suggest a solution if you had mentioned how you are running php scripts in java app.
Basic thing here is you should always call your php file using classpath or path associated within the project
PHP php = new PHP("classpath:/com/demo/phpfile.php");
or sometimes you could use(os path if set up correctly) path of file as accessed by you operating system.
C:\websites\www\myproject\phpfile.php(example windows path)
if you are accessing files like http://localhost/myproject/phpfile.php
then the php file is executed by the wamp server and html output returned. so you do not get the php script.
If you are trying to run java inside php then you could call php files in the manner http://localhost/myproject/phpfile.php to see the end result.

Tomcat + Jboss encoding error

I have a cluster with different os(windows and gnu/linux) running an app with JBOSS(with javabeans made by my team) and the "front-end" with Tomcat.
Every time that the app is running in a gnu/linux the system broke all the encode(ã,é,õ,á). The chartset of the html is utf-8.
I saw a solution for this using getBytes(utf-8) to convert and force the String to be on utf-8 of the os. But there is a lot of Strings and the code will be "polluted" if i use this for every string.
There is any other solution?
This was happening because all data coming from the sybase(database) was with wrong encoding. To resolve we added a flag on connection url( CHARSET=iso_1 ).

Precompiled JSP and Servlets on a Weblogic server (UNIX)

We have a web application hosted on this webLogic server on a UNIX machine. Its primarily a JSP/Servlet based app. Whenever we do a modification/enhancemment to any one of those JSps or servlets, I precompile them on my local and deploy them on the UNIX system. For example, if there is a file called GetIdServlet.class, we usually rename the existing file to say GetIdServlet.class1 and then put in the new file as GetIdServlet.class. This is just to be able to revert back to the original file in case they are needed. However, I notice very strange behaviour. The application loses some functionality whenever we stop and start the server. The functionality may be back on the next or a few restarts after that. For example, a submit button that is supposed to direct it to the next page just stops working. It may start working after a few restart.
However on my local(Eclipse + webLogic) there is absolutely no issue. Everything works fine. Any ideas on what's going wrong?
You are using Unix Environment and i assume that the local desk setup used is windows OS or MAC. thus, when you copy the class files you are using some tool like WinSCP.
in case so, then please set the copy settings of such tool to use binary method of copying the files.
Example in WinSCP. go to Options->Preferences->Select Transfer in the Side Menu->under the Transfer Mode section, Select Binary option as the Transfer Mode. This will ensure that the binary replica is created on the Unix environment and that no data is lost in the transfer.

Categories