Studiewijzer module 10
JDBC


Een JDBC 4+ Driver heeft altijd het bestand: META-INF/services/java.sql.Driver.

Bij JDBC <4, moest altijd een eerste classloader-aanroep gedaan worden naar de Driver. Bijvoorbeeld: Class.forName("oracle.jdbc.driver.OracleDriver").

Statement

  • execute(sql) geeft een boolean terug, met true als het resultaat een resultset is, false als het een updatecount is.

  • executeUpdate(sql) geeft het aantal rijen terug dat geüpdated is.

  • executeQuery(sql) geeft een ResultSet terug.

  • execute(sql) kan voor zowel SELECT als CUD-queries gebruikt worden. De anderen gooien een SQLExecption bij verkeerd gebruik.

Resultset

  • CONCUR_READ_ONLY: The ResultSet object cannot be updated using the ResultSet interface.

  • CONCUR_UPDATABLE: The ResultSet object can be updated using the ResultSet interface.

  • TYPE_FORWARD_ONLY: The result set cannot be scrolled; its cursor moves forward only, from before the first row to after the last row. The rows contained in the result set depend on how the underlying database generates the results. That is, it contains the rows that satisfy the query at either the time the query is executed or as the rows are retrieved.

  • TYPE_SCROLL_INSENSITIVE: The result can be scrolled; its cursor can move both forward and backward relative to the current position, and it can move to an absolute position. The result set is insensitive to changes made to the und


« Vorige module