110 likes | 231 Views
Java / Web aandachtgebieden. JDBC 4.0 Preview. JDBC 4.0 in 10 minutes. What is JDBC Why JDBC 4.0 New in JDBC 4.0 Q and maybe A. JDBC 4.0 in 10 minutes. What is JDBC? The JDBCTM API provides programmatic access to relational data from the JavaTM programming language.
E N D
Java / Web aandachtgebieden JDBC 4.0 Preview
JDBC 4.0 in 10 minutes • What is JDBC • Why JDBC 4.0 • New in JDBC 4.0 • Q and maybe A
JDBC 4.0 in 10 minutes What is JDBC? The JDBCTM API provides programmatic access to relational data from the JavaTM programming language. Using the JDBC API, applications written in the Java programming language can execute SQL statements, retrieve results, and propagate changes back to an underlying data source. The JDBC API can also be used to interact with multiple data sources in a distributed, heterogenous environment. The JDBC API is based on the X/Open SQL CLI, which is also the basis for ODBC. JDBC provides a natural and easy-to-use mapping from the Java programming language to the abstractions and concepts defined in the X/Open CLI and SQL standards. Since its introduction in January 1997, the JDBC API has become widely accepted and implemented. The flexibility of the API allows for a broad range of implementations. Duh! We already knew that.
JDBC 4.0 in 10 minutes • Why JDBC 4.0 ? • It’s new, In fact it does not exit yet. • Expected in Java 6 in 2006 • JDBC is one of the few Java API’s I played with. • It’s one of the most important things for an Oracle/Java developer
JDBC 4.0 in 10 minutes • What’s New! • SQLXML support • Connection management • Enhanced SQLExceptions • Ease of use • Annotations • ROWID data type • Automatic driver loading • Enhanced BLOB and CLOB support • Wrapper Pattern • National Character set Conversion support
JDBC 4.0 in 10 minutes • SQLXML support Code sample 1 Just put the result in a string to process further. SQLXML xmlVal= rs.getSQLXML(1); String xmlstr = xmlVal.getString(); Code sample 2 Put the content of SQLXML in an object. javax.xml.stream.XMLStreamReader
JDBC 4.0 in 10 minutes SQLXML xmlVal= rs.getSQLXML(1); XMLStreamReader aReader = xmlVal.createStreamReader(); while(aReader.hasNext()) { // parse the next event for (int event = reader.next(); event != XMLStreamConstants.END_DOCUMENT; event = reader.next()) { switch (event) { case XMLStreamConstants.START_ELEMENT: // process the element … break; } }
JDBC 4.0 in 10 minutes • Connection management Connection Added setCientInfo() Added getClientInfo() Added isValid() PreparedStatement Added setPoolable() Added isPoolable() (default TRUE)
JDBC 4.0 in 10 minutes • Enhanced SQLExceptions • Added SQLNonTransientException • SQLSyntaxErrorException • SQLInvalidAuthorizationSpecException • SQLIntegrityConstraintViolationException • SQLDataException • SQLNonTransientConnectionException • Added SQLTransientException Error might not occur when statement is re-executed. • SQLTimeoutException • SQLTransactionRollbackException • SQLTransientConnectionException
JDBC 4.0 in 10 minutes Questions
JDBC 4.0 in 10 minutes Sources. JDBC 4.0 API Specification - Early Draft Release 2 Available on http://java.sun.com And http://java.sys-con.com/read/111252.htm