本示例演示 UltraLiteJ 对以其它顺序来处理行的支持。
转到以下目录:samples-dir\UltraLiteJ。
有关 samples-dir 缺省位置的信息,请参见示例目录。
运行 CreateSales 示例:
rundemo CreateSales |
请参见示例:创建销售数据库。
运行以下命令(此命令区分大小写):
rundemo SortTransactions |
// ***************************************************** // Copyright (c) 2006-2010 iAnywhere Solutions, Inc. // Portions copyright (c) 2006-2010 Sybase, Inc. // All rights reserved. All unpublished rights reserved. // ***************************************************** // This sample code is provided AS IS, without warranty or liability // of any kind. // // You may use, reproduce, modify and distribute this sample code // without limitation, on the condition that you retain the foregoing // copyright notice and disclaimer as to the original iAnywhere code. // // ********************************************************************* package com.ianywhere.ultralitej.demo; import com.ianywhere.ultralitej12.*; /** Illustrate use of SortCursor to produce a * stream of rows in a different order. */ public class SortTransactions { /** Mainline. * @param args program arguments (not used) */ public static void main( String[] args ) { try { Configuration config = DatabaseManager.createConfigurationFile( "Sales.ulj" ); Connection conn = DatabaseManager.connect( config ); PreparedStatement stmt = conn.prepareStatement( "SELECT inv_no, prod_no, quantity FROM InvoiceItem" + " ORDER BY prod_no" ); ResultSet cursor = stmt.executeQuery(); for( ; cursor.next(); ) { int inv_no = cursor.getInt( 1 /* "inv_no" */ ); int prod_no = cursor.getInt( "prod_no" ); //access by name int quantity = cursor.getInt( 3 /* "quantity" */ ); Demo.display( Integer.toString( prod_no ) + ' ' + Integer.toString( inv_no ) + ' ' + Integer.toString( quantity ) ); } conn.release(); Demo.display( "SortTransactions completed successfully" ); } catch( ULjException exc ) { Demo.displayException( exc ); } } } |
![]() |
使用DocCommentXchange 讨论此页。
|
版权 © 2010, iAnywhere Solutions, Inc. - SQL Anywhere 12.0.0 |