{"id":1576,"date":"2006-05-01T11:28:00","date_gmt":"2006-05-01T11:28:00","guid":{"rendered":"http:\/\/gleamynode.net\/articles\/1576\/improvements-in-jdbc-40"},"modified":"2022-12-28T01:47:43","modified_gmt":"2022-12-27T16:47:43","slug":"improvements-in-jdbc-4-0","status":"publish","type":"post","link":"https:\/\/vault.motd.kr\/wordpress\/posts\/1576\/improvements-in-jdbc-4-0\/","title":{"rendered":"Improvements in JDBC 4.0"},"content":{"rendered":"
This is the summary of an article from JavaWorld.com<\/a>.<\/p>\n interface EmployeeQueries extends BaseQuery { @Update (sql=”delete from employee”) Connection con = … catch(SQLException ex) { java.sql.Wrapper supports non-standard vendor-dependent types safely<\/p>\n PreparedStatement ps = …; This is very similar to a simple downcasting pattern which uses instanceof keyword, but it is different and flexible in that isWrappedFor(…) and unwrap(…) can perform downcasting recursively and programmatically by its definition. To put simply, this is a safe downcasting pattern for the decorator pattern. This pattern will be also very useful for other use cases, not just for connection pool implementations.<\/p>\n JavaWorld\uc5d0\uc11c \uc77d\uc740 \uae30\uc0ac<\/a>\uc758 \uc694\uc57d\uc785\ub2c8\ub2e4.<\/p>\n interface EmployeeQueries extends BaseQuery { @Update (sql=”delete from employee”) Connection con = … catch(SQLException ex) { java.sql.Wrapper\ub294 \ubca4\ub354 \uc885\uc18d\uc801 \ud0c0\uc785\uc744 \uc548\uc804\ud558\uac8c \uc0ac\uc6a9\ud560 \uc218 \uc788\ub294 \ubc29\ubc95\uc744 \uc81c\uacf5<\/p>\n PreparedStatement ps = …; \uc774\uac83\uc740 instanceof \ud0a4\uc6cc\ub4dc\ub97c \uc0ac\uc6a9\ud558\ub294 \uae30\uc874\uc758 \ub2e8\uc21c\ud55c \ub2e4\uc6b4\uce90\uc2a4\ud305 \ud328\ud134\uacfc \uc544\uc8fc \ube44\uc2b7\ud558\uc9c0\ub9cc, isWrappedFor(…)\uc640 unwrap(…)\uac00 \ub2e4\uc6b4\uce90\uc2a4\ud305\uc744 \uc7ac\uadc0\uc801 \ubc0f \ud504\ub85c\uadf8\ub7a8\uc801\uc73c\ub85c \uc218\ud589\ud560 \uc218 \uc788\ub2e4\ub294 \uc810\uc5d0\uc11c \ub2e4\ub985\ub2c8\ub2e4. \uac04\ub2e8\ud788 \ub9d0\ud574 \ub370\ucf54\ub808\uc774\ud130 \ud328\ud134\uc5d0\uc11c \uc4f8 \uc218 \uc788\ub294 \uc548\uc804\ud55c \ub2e4\uc6b4\uce90\uc2a4\ud305 \ud328\ud134\uc778 \uc148\uc785\ub2c8\ub2e4. \uc774 \ud328\ud134\uc740 \ucee4\ub125\uc158 \ud480 \uad6c\ud604 \ubfd0\ub9cc \uc544\ub2c8\ub77c \ub2e4\ub978 \ube44\uc2b7\ud55c \uacf3\uc5d0\uc11c\ub3c4 \uc720\uc6a9\ud558\uac8c \uc801\uc6a9\ud560 \uc218 \uc788\uc744 \uac83 \uac19\ub124\uc694.<\/p>\n This is the summary of an article from JavaWorld.com. Annotations and the generic DataSet DataSet extends java.util.List. has a java.sql.ResultSet (when connected) or a javax.sql.rowset.CachedRowSet (when disconnected) in it. Query is instantiated by Connection.createQueryObject() or DataSource.createQueryObject() interface EmployeeQueries extends BaseQuery { @Select (sql=”SELECT employeeId, firstName, lastName FROM employee”) DataSet getAllEmployees (); @Update… Continue reading Annotations and the generic DataSet<\/h3>\n
\n
\n
\n
\n @Select (sql=”SELECT employeeId, firstName, lastName FROM employee”)
\n DataSet getAllEmployees ();<\/p>\n
\n int deleteAllEmployees ();
\n}<\/p>\n
\nEmployeeQueries empQueries = con.createQueryObject (EmployeeQueries.class);
\nDataSet empData = empQueries.getAllEmployees ();
\nfor (Employee e: empData) {
\n System.out.println(e.getFirstName());
\n}\n<\/p><\/blockquote>\nException Handling Hierarchies<\/h3>\n
\n
\n for(Throwable t : ex) {
\n System.out.println(“exception:” + t);
\n }
\n}\n<\/p><\/blockquote>\nLeverage nonstandard vendor implemented resources<\/h3>\n
\nif (ps.isWrappedFor(OraclePreparedStatement.class)) {
\n OraclePreparedStatement ops = ps.unwrap(OraclePreparedStatement.class);
\n}\n<\/p><\/blockquote>\nMiscellaneous<\/h3>\n
\n
\n
\n
\n\uc5b4\ub178\ud14c\uc774\uc158\uacfc DataSet<\/h3>\n
\n
\n
\n
\n @Select (sql=”SELECT employeeId, firstName, lastName FROM employee”)
\n DataSet getAllEmployees ();<\/p>\n
\n int deleteAllEmployees ();
\n}<\/p>\n
\nEmployeeQueries empQueries = con.createQueryObject (EmployeeQueries.class);
\nDataSet empData = empQueries.getAllEmployees ();
\nfor (Employee e: empData) {
\n System.out.println(e.getFirstName());
\n}<\/p><\/blockquote>\n\uc608\uc678 \ucc98\ub9ac\uc758 \uacc4\uce35\ud654<\/h3>\n
\n
\n for(Throwable t : ex) {
\n System.out.println(“exception:” + t);
\n }
\n}\n<\/p><\/blockquote>\n\ubca4\ub354 \uc885\uc18d\uc801 \uc790\uc6d0\uc758 \ud65c\uc6a9<\/h3>\n
\nif (ps.isWrappedFor(OraclePreparedStatement.class)) {
\n OraclePreparedStatement ops = ps.unwrap(OraclePreparedStatement.class);
\n}\n<\/p><\/blockquote>\n\uae30\ud0c0<\/h3>\n
\n
\n
\n