Sending mail error, javax.mail.MessagingException: Could not connect to SMTP host: localhost, port: 25;

Error is self explainatory: javax.mail.MessagingException: Could not connect to SMTP host: localhost, port: 25; You have no SMTP server on localhost, but you configure it there : So you must: either configure a local SMTP server as a relay on your local system (Postfix or sendmail are two well knows servers) of configure a dummy server that simply … Read more

Java: How to set Precision for double value?

You can’t set the precision of a double (or Double) to a specified number of decimal digits, because floating-point values don’t have decimal digits. They have binary digits. You will have to convert into a decimal radix, either via BigDecimal or DecimalFormat, depending on what you want to do with the value later. See also my answer to this … Read more

How to serialize an object into a string

Sergio: You should use BLOB. It is pretty straighforward with JDBC. The problem with the second code you posted is the encoding. You should additionally encode the bytes to make sure none of them fails. If you still want to write it down into a String you can encode the bytes using java.util.Base64. Still you should use … Read more

When to use static methods

One rule-of-thumb: ask yourself “Does it make sense to call this method, even if no object has been constructed yet?” If so, it should definitely be static. So in a class Car you might have a method: …which would be static, because one might want to know what 35mpg converts to, even if nobody has ever built … Read more

Picked up _JAVA_OPTIONS: -Xmx256M

The message “Picked up _JAVA_OPTIONS” implies that the Java runtime has found this setting in your environment variables. The solution depends on which operating system you are running. But assuming it is Windows, there are two possibilities: The most likely is that it is picking it up from the System or User environment. Try opening … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)