#!/usr/bin/env python import string, cgi, os, whrandom, pickle, sys import cgitb; cgitb.enable() #sys.path.insert(0, '/home/mu.org/home/gus/fm/fmblog') #import fmbloglib,fmblog print 'Content-type: text/html\r\n' print ''' gus mueller
Sick of typing jdbc/sql calls everywhere in your servlets or jsps or whatever? Try this method on for size:


usage:
int rows_updated = executeUpdate("insert into something (a, b, c) values (?, ?, ?)",
                                  new String [ ] {var_a, var_b, var_c});

public int executeUpdate(String query, String [ ] params) { //get your connection from a database pool. Connection dbconn = getConnection(); PreparedStatement stmt = null; int r = -1; try { stmt = dbconn.prepareStatement(query); for (int i = 1; i <= params.length; i++) { stmt.setString(i, params[i - 1]); } r = stmt.executeUpdate(); } catch(Exception e) { e.printStackTrace(System.err); } finally { try { if (stmt != null) stmt.close(); } catch(SQLException e) { e.printStackTrace(System.out); } //return your connection setConnection(dbconn); } return r; }

All things copyright © 2001, 2002 August Mueller

gmdc:
flying meat
contact
resume
photos
images
free font
cocoa bits
java bits
unix bits
osx bits
cvsdist
my words
mcommand
ja
links
my rss feed
book list
who\'s linken\'
login
wishlist
theories

people
andy
byron
jeff
jeremy
joe
kory
lynn
mary
murphy
ryan d

when bored
slashdot
maccentral
y! most viewed
cars
there gus
explodingdog
the onion
dotw
tonypierce
prior art
chimera

resources
Cafe au Lait
Cafe con Leche
design patterns
anitpatterns
java r.o.t.d
c.l.c
c.l.j
c.s.m.p.h
c.s.m.p.c



'''