Value from last inserted row in DB [duplicate]

This question already has answers here: How to get a value from the last inserted row? [duplicate] (14 answers) Closed 8 years ago. Is there some way to get a value from the last inserted row? I am inserting a row where the PK will automatically increase due to sequence created, and I would like … Read more

Java -jar : access external configuration file

I’m looking to do something which I thought was not going to be difficult. I have an application that I’d like to package up as a jar because I’ve got ~30 dependencies and I would like to be able to deploy a single file. I have some configuration files – a properties file and a … Read more

Limitation in Java HttpUrlConnection getting content length

Right so, I started my project on creating a Java download manager which is going nicely. The only problem I am seeing at the moment is when i request the content length of the URL. When i use the method provided by HttpUrlConnection’s getContentLength, it returns an Int. This is great if i was only … Read more

Need help returning object in thread run method

I have a Java class that extends Thread, it basically looks like the following: public class HttpRequestDispatcher extends Thread { private String url; private String method; // GET or POST private byte[] postData; public HttpRequestDispatcher(String url, String method, byte[] postData) { this.url = url; this.method = method; this.postData = postData; } public HttpRequestDispatcher(String url, String … Read more

Replace the first letter of a String in Java?

I’m trying to convert the first letter of a string to lowercase. value.substring(0,1).toLowerCase() + value.substring(1) This works, but are there any better ways to do this? I could use a replace function, but Java’s replace doesn’t accept an index. You have to pass the actual character/substring. It could be done like this: value.replaceFirst(value.charAt(0), value.charAt(0).toLowerCase()) Except … Read more

Any reason not to always log stack traces?

Encountered a frustrating problem in our application today which came down to an ArrayIndexOutOfBounds exception being thrown. The exception’s type was just about all that was logged which is fairly useless (but, oh dear legacy app, we still love you, mostly). I’ve redeployed the application with a change which logs the stack trace on exception … Read more

Is there a way to securely store user data on an Android device?

I’m writing an application wherein users will sometimes make orders through it. I want to give users the option to save their billing info (name, address, etc.) so that it can be quickly restored later if they want to make another order. The user will enter a password to secure the data. Obviously I can’t … Read more

Calling Python from Java through scripting engine (jython)?

I’m trying to call Jython from a Java 6 application using javax.script: import javax.script.ScriptEngine; import javax.script.ScriptEngineManager; import javax.script.ScriptException; public class jythonEx { public static void main (String args[]) throws ScriptException { ScriptEngineManager mgr = new ScriptEngineManager(); ScriptEngine pyEngine = mgr.getEngineByName(“python”); try { pyEngine.eval(“print \”Python – Hello, world!\””); } catch (Exception ex) { ex.printStackTrace(); } } … Read more