Hi, am new to this field.I haven't idea about Hashmap.But i wrote this pgm it is perfectly working(Fetching the data from database).But I don't know abt this process is correc or not. Anyone help me .Urgently I need this one
public void close() throws SQLException { dbCon.close(); }
public ResultSet execSQL(String sql) throws SQLException{ Statement s = dbCon.createStatement(); ResultSet r = s.executeQuery(sql); return (r == null) ? null : r; }
public int updateSQL(String sql) throws SQLException{ Statement s = dbCon.createStatement(); int r= s.executeUpdate(sql); return (r == 0) ? 0 : r; }
}
Jeroen T Wenting
Ranch Hand
Joined: Apr 21, 2006
Posts: 1847
posted
0
Well, coding scriptlets (and especially longer ones) is strongly discouraged in favour of using JSTL in combination with servlets.
Creating static variables in JSPs is extremely dangerous. Essentially you're working with globals, which can have very nasty consequences when you have multiple simultaneous requests.
You're creating a new database connection for every database request (of which you have several per HTTP request), and never closing them. MASSIVE nono! Extremely slow, drains resources like there was no tomorrow (try for example running it against a server on which you only have a license for 5 connections, your third page request will go seriously wrong), and completely unnecessary.