- Home
- Products
- Integration
- Tutorial
- Barcode FAQ
- Purchase
- Company
USING STRONGLY TYPED INTERFACES WITH JPUBLISHER in Font
CHAPTER 10 USING STRONGLY TYPED INTERFACES WITH JPUBLISHER Code 39 Full ASCII Encoder In None Using Barcode printer for Font Control to generate, create USS Code 39 image in Font applications. www.OnBarcode.comCode128 Printer In None Using Barcode generator for Font Control to generate, create USS Code 128 image in Font applications. www.OnBarcode.comString selectStmt = "select value(a) from address_table a"+ " where line1 = for update nowait"; pstmt = connection.prepareStatement ( selectStmt ); pstmt.setString( 1, "145 Apt # 7" ); orset = (OracleResultSet) pstmt.executeQuery(); if ( orset.next() ) { myAddress = (MyAddressORAData) orset.getORAData(1, MyAddressORAData.getORADataFactory() ); myAddress.setStreet ( "Wonderful St" ); String updateStmt = "update address_table a" + " set value(a) = " + " where a.line1 = "; opstmt = (OraclePreparedStatement) connection.prepareStatement ( updateStmt ); opstmt.setORAData (1, myAddress ); opstmt.setString (2, "145 Apt # 7" ); int rows = opstmt.executeUpdate(); System.out.println ( "Updated " + rows + " rows " ); } connection.commit(); } finally { JDBCUtil.close( orset ); JDBCUtil.close( opstmt ); } } Deleting Objects There is nothing special about deleting an object. It is a simple relational statement, as illustrated in the following _demoDelete() method: private static void _demoDelete( Connection connection) throws SQLException, ClassNotFoundException { PreparedStatement pstmt = null; try { String deleteStmt = "delete address_table a" + " where a.line1 like "; pstmt = connection.prepareStatement ( deleteStmt ); pstmt.setString (1, "Mountain View" ); int rows = pstmt.executeUpdate(); System.out.println ( "Deleted " + rows + " row(s) " ); connection.commit(); } QR Code 2d Barcode Creation In None Using Barcode creator for Font Control to generate, create QR-Code image in Font applications. www.OnBarcode.comPainting PDF 417 In None Using Barcode encoder for Font Control to generate, create PDF 417 image in Font applications. www.OnBarcode.comCHAPTER 10 USING STRONGLY TYPED INTERFACES WITH JPUBLISHER
Draw Barcode In None Using Barcode printer for Font Control to generate, create Barcode image in Font applications. www.OnBarcode.comData Matrix ECC200 Creator In None Using Barcode maker for Font Control to generate, create Data Matrix 2d barcode image in Font applications. www.OnBarcode.comfinally { JDBCUtil.close( pstmt ); } } } Now that you know how to use the SQLData interface and the Oracle extension interfaces ORAData and ORADataFactory, let s compare the two approaches. EAN / UCC - 13 Creation In None Using Barcode encoder for Font Control to generate, create European Article Number 13 image in Font applications. www.OnBarcode.comMake Uniform Symbology Specification Codabar In None Using Barcode generation for Font Control to generate, create USD-4 image in Font applications. www.OnBarcode.comSQLData vs. ORAData and ORADataFactory
Create Code-39 In Java Using Barcode creation for Android Control to generate, create Code39 image in Android applications. www.OnBarcode.comCode39 Creator In None Using Barcode creation for Font Control to generate, create ANSI/AIM Code 39 image in Font applications. www.OnBarcode.comIn this section, we ll highlight the differences between the SQLData and ORAData interfaces. Note that there may be times when you have to use ORAData for example, if you want to create a custom class for a nonstandard Oracle-specific type. In practice, there are no major advantages or disadvantages to using either approach. The main advantage of using the SQLData interface, at least in theory, is that it is a JDBC standard and makes your Java code more portable across databases. However, at the time of this writing, the implementation and use of objects in different databases varies so much that the majority of such code contains vendor-dependent code anyway. Using the ORAData and ORADataFactory interfaces, on the other hand, has the following advantages (none of which is really earth-shattering): The ORAData interface has more flexibility than the SQLData interface. It lets you provide a mapping between Java object types and any SQL type supported by the oracle.sql package. For example, you can use it if you want to create a custom class for a nonstandard Oracle-specific type such as oracle.sql.BFILE. The ORAData interface does not require a type map to map the object type to Java classes. According to the documentation, using the ORAData interface leads to better performance since ORAData works directly with the internal format the driver uses to hold Oracle objects. This means there is no conversion required to hold the data. The tests I conducted to verify this statement were not conclusive, as in some cases, I actually found SQLData to be faster. So my advice is that you should use this criterion for choosing between the two approaches in your application only after running appropriate benchmarks in the context of your application. Make PDF417 In None Using Barcode generation for Office Excel Control to generate, create PDF 417 image in Excel applications. www.OnBarcode.comCode 39 Extended Scanner In Visual Studio .NET Using Barcode scanner for VS .NET Control to read, scan read, scan image in .NET applications. www.OnBarcode.comCHAPTER 10 USING STRONGLY TYPED INTERFACES WITH JPUBLISHER
Scanning Code 39 Extended In Java Using Barcode scanner for Java Control to read, scan read, scan image in Java applications. www.OnBarcode.comCode 128 Code Set C Encoder In Objective-C Using Barcode maker for iPad Control to generate, create ANSI/AIM Code 128 image in iPad applications. www.OnBarcode.comA Note on Separating Domain Objects from the Persistence Mechanism
Generate UCC - 12 In VS .NET Using Barcode creation for Reporting Service Control to generate, create EAN / UCC - 13 image in Reporting Service applications. www.OnBarcode.comANSI/AIM Code 39 Creator In None Using Barcode drawer for Software Control to generate, create Code 39 Full ASCII image in Software applications. www.OnBarcode.comYou may have noticed that regardless of whether you use SQLData or ORAData, the code generated by JPublisher suffers from what many would justifiably consider a serious drawback. The problem is that the custom classes (which are domain objects that is, objects that represent end-user business entities such as an Address, a Person, and so on) are tightly coupled with the persistence mechanism. For example, the getAddress() method in the generated domain class MyAddressAuto executes the method get_address() to retrieve the data from the database. Even if database independence is not a goal of your design, it is a good coding practice to separate out the persistence mechanism that you use to save and retrieve your domain objects from the domain objects themselves. This is a fairly involved topic in its own right, and it s beyond the scope of this book. Many well-documented frameworks (such as the Spring framework) are available, using which this objective can be achieved. Barcode Generation In VS .NET Using Barcode creation for Reporting Service Control to generate, create Barcode image in Reporting Service applications. www.OnBarcode.comPDF-417 2d Barcode Encoder In None Using Barcode encoder for Online Control to generate, create PDF417 image in Online applications. www.OnBarcode.comSummary Barcode Scanner In Java Using Barcode Control SDK for BIRT reports Control to generate, create, read, scan barcode image in BIRT reports applications. www.OnBarcode.comQR Code ISO/IEC18004 Maker In Java Using Barcode encoder for Java Control to generate, create QR Code ISO/IEC18004 image in Java applications. www.OnBarcode.comIn this chapter, you learned what strongly typed interfaces are. You examined the JDBC standard interface, SQLData, and the Oracle extension interfaces, ORAData and ORADataFactory. You learned about the various options provided by JPublisher, a utility that generates custom classes mapping SQL objects to Java for you. You also learned, through examples, how to use JPublisher to generate custom classes that implement either SQLData or ORAData interfaces that allow you to retrieve and manipulate objects stored in the database. In the next chapter, we will examine how to use collections and references in a JDBC program.
|
|