Is there a way to run php server**(remote)** scripts from a java program (with secured/encrypted connection). Answer Visit (make post or get HTTP request) php page from your java program, for example, via HttpUrlConnection type
PreparedStatement setNull(..)
Java PreparedStatement provides a possibility to explicitely set a Null value. This possibility is: Are the semantics of this call the same as when using a specific setType with a null parameter? ? Answer This guide says: 6.1.5 Sending JDBC NULL as an IN parameter The setNull method allows a programmer to sen…
Find a class somewhere inside dozens of JAR files?
How would you find a particular class name inside lots of jar files? (Looking for the actual class name, not the classes that reference it.) Answer Eclipse can do it, just create a (temporary) project and put your libraries on the projects classpath. Then you can easily find the classes. Another tool, that co…
How do I manually configure a DataSource in Java?
I’m trying to follow Sun’s JDBC tutorial at http://java.sun.com/docs/books/tutorial/jdbc/basics/connecting.html It gives the following example code: This code doesn’t compile because the DataSource interface has none of these methods, except for the getConnection() method invoked last. (Here…
How can I parse a date including timezone with Joda Time
This snippet of code always parses the date into the current timezone, and not into the timezone in the string being parsed. It outputs: whereas I expect: Any ideas what I’m doing wrong? Answer OK, further Googling gave me the answer to my own question: use withOffsetParsed(), as so: This works.
Reading a remote file using Java
I am looking for an easy way to get files that are situated on a remote server. For this I created a local ftp server on my Windows XP, and now I am trying to give my test applet the following address: and of course I receive the following error: URI scheme is not “file” I’ve been trying som…
Prevent round off in String.format(“%.2f”, doubleValue) in Java
How do I prevent String.format(“%.2f”, doubleValue); from rounding off (round half up algorithm) instead of just truncating it? e.g. after formatting, I just want to discard the last digit, I know there are other ways to do this, I just want to know if this is possible using the String.format. Ans…
How do I convert from int to Long in Java?
I keep finding both on here and Google people having troubles going from long to int and not the other way around. Yet I’m sure I’m not the only one that has run into this scenario before going from int to Long. The only other answers I’ve found were “Just set it as Long in the first p…
C# Java HashMap equivalent
Coming from a Java world into a C# one is there a HashMap equivalent? If not what would you recommend? Answer Dictionary is probably the closest. System.Collections.Generic.Dictionary implements the System.Collections.Generic.IDictionary interface (which is similar to Java’s Map interface). Some notable…
Java UTF-8 strange behaviour
I am trying to decode some UTF-8 strings in Java. These strings contain some combining unicode characters, such as CC 88 (combining diaresis). The character sequence seems ok, according to http://www.fileformat.info/info/unicode/char/0308/index.htm But the output after conversion to String is invalid. Any ide…