// define sql query
String sql = "select firstname from users";
// initialize database connection objects
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
// get JNDI JDBC connection
InitialContext ctxt = new InitialContext();
DataSource ds = (DataSource) ctxt.lookup("jdbc/TrackIt");
conn = ds.getConnection();
// run sql objects
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
// retrieve results
while (rs.next()) {
rs.getInt("firstname"));
}
Subscribe to:
Post Comments (Atom)
2 comments:
Good, basic setup, Just what I needed.
Article writing is also a fun, if you know after that you can write
if not it is complicated to write.
Also visit my webpage legalsoundz.com
Post a Comment