Search Java Code Snippets


  Help us in improving the repository. Add new snippets through 'Submit Code Snippet ' link.





Java - Code Samples

 Sample 1. Code Sample / Example / Snippet of java.sql.Connection

  public String prepareBindExecute(HrConnection state) throws SQLException {

Connection con = state.con;

Statement st = null;

ResultSet rs = null;

String ename = null;

try {

final PreparedStatement ps =

con.prepareStatement("select name from emps where empid = ?");

st = ps;

ps.setInt(1, state.id);

rs = ps.executeQuery();

rs.next();

ename = rs.getString(1);

} finally {

close(rs, st);

}

return ename;

}


   Like      Feedback      java.sql.Connection



Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Enter your email address:
Delivered by FeedBurner