Java JDBC Get Last Inserted ID

If you don’t like stored procedures wherein the value returned is the last inserted id, you can get it via JDBC code. Using either a Statement or PreparedStatement class, you retrieve the ResultSet using the getGeneratedKeys() method. Sample code below.

ResultSet rskey = ps.getGeneratedKeys();
 
if (rskey != null && rskey.next()) {
  int lastInsertedId = rskey.getInt(1);
}

Like what you see? Buy me a cup of coffee. Or subscribe to my feeds.


(3 votes, average: 3.67 out of 5)
 Loading ...

Unix nohup Log File And Error File

Unix type operating systems have a command called nohup which means no hang up. Problem with running applications especially when you log off from the system, is that the application that was running gets terminated as well. To avoid this problem, we use the nohup command. If in case we want to separate the log file from the error file, this is the way to do it:

nohup ./[file] 2>[error_file] > [log_file]

It’s as simple as that.

Like what you see? Buy me a cup of coffee. Or subscribe to my feeds.


(1 votes, average: 5.00 out of 5)
 Loading ...

EntreCash Sell Your EntreCard Credits

Ever wondered what good Entrecard credits can do other than getting your widget advertised in other blogs? Here’s the thing. I’ve seen some sites that do have payment forms in PayPal that lets you buy EC credits from them. I too wanted one, but right now, I have no idea how to implement it nor where to start. I came across a new site that just started called EntreCash. You can sell your EC credits here if you want. As with all other sites, it is standard to register and have an account. I won’t go into detail how to advertise there into selling your EC credits as the site’s user interface is fairly easy to navigate through. Be sure you also have a PayPal account as it will be where your payment will go to in case someone does buy your EC credits. I hope to have some success here too. Hopefully, I can get my first payment in PayPal through here…

To go to EntreCash’s website, click here.

Like what you see? Buy me a cup of coffee. Or subscribe to my feeds.


(1 votes, average: 5.00 out of 5)
 Loading ...

Javascript Detect Broken Image

We have no way to know if an image is broken or not especially if we are just hot linking it from some other site. Javascript’s onerror function just does that. To add a no-image-file as replacement instead of the broken image icon (which would make your site look unprofessional), use this function below.

function onImgError(source) {
  source.src = "no-image-125px.gif";
  // disable onerror to prevent endless loop
  source.onerror = "";
  return true;
}

and call it using this <img src="test.gif" onerror="onImgError(this)"/>

tip from: http://www.tech-evangelist.com/2007/09/15/missing-image-fix/

Like what you see? Buy me a cup of coffee. Or subscribe to my feeds.


(3 votes, average: 5.00 out of 5)
 Loading ...