This shows you the differences between two versions of the page.
|
wettstein:java [2010-03-05 14:45] frank.wettstein |
wettstein:java [2010-07-01 12:36] (current) frank.wettstein |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | = Collections = | ||
| + | |||
| + | Bag (org.apache.commons) -> Defines a collection that counts the number of times an object appears in | ||
| + | the collection. | ||
| + | |||
| + | Buffer (org.apache.commons) -> Defines a collection that allows objects to be removed in some well-defined order. (FIFO, LRU cache) | ||
| + | |||
| + | |||
| + | |||
| + | |||
| = Zeichenketten = | = Zeichenketten = | ||
| Line 278: | Line 288: | ||
| -XX:+HeapDumpOnOutOfMemoryError : Creates a heapDump | -XX:+HeapDumpOnOutOfMemoryError : Creates a heapDump | ||
| + | = JDBC = | ||
| + | |||
| + | Null-Abfragen: | ||
| + | <code> | ||
| + | String s = rs.getString( column ); | ||
| + | if ( rs.wasNull() ) | ||
| + | System.out.println( "SQL-NULL" ); | ||
| + | </code> | ||
| + | |||
| + | Mehrere Updated gleichzeitig machen: | ||
| + | <code> | ||
| + | int[] updateCounts = null; | ||
| + | try | ||
| + | { | ||
| + | con.setAutoCommit( false ); | ||
| + | Statement s = con.createStatement(); | ||
| + | s.addBatch( "INSERT INTO Lieferanten VALUES (x,y,z)" ); | ||
| + | s.addBatch( "INSERT INTO Lieferanten VALUES (a,b,c)" ); | ||
| + | s.addBatch( "INSERT INTO Lieferanten VALUES (d,e,f)" ); | ||
| + | updateCounts = s.executeBatch(); | ||
| + | } | ||
| + | catch ( BatchUpdateException e ) { con.rollback(); } | ||
| + | catch ( SQLException e ) { /* Behandeln! */ } | ||
| + | </code> | ||
| + | |||
| + | Das ResultSet muss immer eine Verbindung mit der Datenbank haben, und ein Aufruf von next() könnte sich die Zei-leninformationen immer von der Datenbank besorgen. Ein ResultSet ist also kein Container, der Daten speichert. Aus diesem Grunde implementiert ResultSet auch nicht die Schnittstelle Serializable. | ||
| + | |||
| + | == Rowset == | ||
| + | |||
| + | === Cached rowset === | ||
| + | A CachedRowSet object is a disconnected rowset, which means that it makes use of a connection to its data source only briefly. It connects to its data source while it is reading data to populate itself with rows and again while it is propagating changes back to its underlying data source. The rest of the time, a CachedRowSet object is disconnected, including while its data is being modified. Being disconnected makes a RowSet object much leaner and therefore much easier to pass to another component. For example, a disconnected RowSet object can be serialized and passed over the wire to a thin client such as a personal digital assistant (PDA). | ||
| + | Bietet Möglichkeit für Paging, Updating, Registering Listeners | ||