Ked to takto pojde dalej, tak zistite, ze najlepsie by bolo pouzivat
daku kniznicku, ktora to bude za vas vzdy zatvarat a ked mam
PreparedStatement tak nech sa nestaram o cislovanie parametrov ,
pripadne nech cely riadok natiahne do pola alebo beanu.
Napriklad : http://jakarta.apache.org/commons/dbutils/
a kod potom moze vyzerat takto :
// Create a QueryRunner that will use connections from
// the given DataSource
QueryRunner run = new QueryRunner(dataSource);
// Execute the query and get the results back from the handler
Object[] result = (Object[]) run.query(
"SELECT * FROM Person WHERE name=?", "John Doe", h);
Samozrejme vam nestaci len prvy riadok ako pole, tak mozete pouzit
ResulSetHandler objekt :
new QueryRunner().query(conn, "select ........ ",new Object[]{id}, // v
poli su dake parametre do PreparedStatement
new ResultSetHandler() {
public Object handle(ResultSet rs) throws SQLException {
while( rs.next()){
// tu je daco uzitocne
}
return null;
}
}
Bye Ra100