Home

Application Program Interface Users` Manual

image

Contents

1. Elements Meaning Mandatorv field with optional items Onlv one field must be provided ADD DROP Optional field with optional item ASC DESC Optional multiple fields are allowed The comma must be in front of every repetition ASC i DESC E xd The code example explains SQL stored procedure iSQL or other command line syntax The following table describes the printing rules used in the code example Rules Meaning Example Indicates optional fields VARCHAR size FIXED VARI ABLE Indicates mandatory fields Indicates f ENABLE DISABLE COMPILE to make sure to select at least one Argument indicating optional or man ENABLE DISABLE COMPILE J datory fields ENABLE DISABLE COMPILE Repetition of the previous argu SQL SELECT ename FROM ment Omit the example codes employee ENAME HSCHOI 20 rows selected Application Program Interface Users Manual iv About This Manual Rules Meaning Example Other svmbols Svmbols other than the above EXEC pl 1 acc NUMBER 11 2 Italic Indicates variable or value that must SELECT FROM table_name be provided by user CONNECT userlD password Small letters Program elements provided by the SELECT ename FROM employee user such as table names co
2. Return Function Name Support Object getObject int columnindex O Object getObject int i Map map X Object getObject String columnName O Object getObject String colName Map map X Ref getRef int i X Ref getRef String colName X int getRow O short getShort int columnindex O short getShort String columnName O Statement getStatement O String getString int columnindex O String getString String columnName O Time getTime int columnIndex O Time getTime int columnindex Calendar cal A Time getTime String columnName O Time getTime String columnName Calendar cal A Timestamp getTimestamp int columnindex O Timestamp getTimestamplint columnindex Calendar cal A Timestamp getTimestamp String columnName O Timestamp getTimestamp String columnName Calendar cal A int getTypel O InputStream getUnicodeStream int columnindex X InputStream getUnicodeStream String columnName X URL getURL int columnindex X URL getURL String columnName X SQLWarning getWarnings O void insertRow X boolean isAfterLast O boolean isBeforeFirst O boolean isFirst O boolean isLast O 21 JDBC JDBC 2 1 Core API and JDBC 2 0 Optional Package API Return Function Name Support boolean last O void moveToCurrentRow O void moveTolnsertRow X boolean next O boolean previous O void refre
3. tx commit lt return service status back to the client gt How to start executing transaction in application client The following example shows application client starts to execute transaction Client tx begin tpm service SERVICE1 tmp service SERVICE2 tx commit Server SERVICE1 lt get service specific data gt EXEC SQL UPDATE lt return service status back to the client gt SERVICE2 lt get service specific data gt EXEC SQL UPDATE lt return service status back to the clients Changing the Existing Application into TPM Application You should follow the process below to change the existing application Precompiler or ODBCCLI into TPM Transaction Performance Mornitoring application with using ALTIBASE XA library 1 You should convert application into service with framework Framework means that application client requests service from its server Certain TPM can make request for using tx_open and tx_close Certain TPM logs on or off application server implicitly 2 You should chanage general connect statement For example you should change EXEC SQL CONNECT statement into tx_open in precompiler and SQLDriverConnect statement into tx_open and SQLCONNECT in ODBCCLI Refer to the process performing ODBC XA for details 3 You should change disconnect statement You should change EXEC SQL DISCONNECT state ment into tx_close in precompiler and SQLDi
4. Examples ADO Examples Dim adoRst Dim adoCnn Dim rsAddRtn Dim strSQL Dim strCnnStr Dim a b c strSQL SELECT FROM T1 WScript StdOut Write Program Start WScript StdOut WriteBlankLines 1 set adoCnn CreateObject ADODB Connection set adoRst CreateObject ADODB Recordset adoRst cursorlocation 3 This indicates to access adoCnn Open Provider Altibase OLEDB DSN altibase odbc This indicates to output records adoRst Open strSQL adoCnn For a 0 To adoRst RecordCount 1 b adoRst Fields 0 c adoRst Fields 1 WScript StdOut Write b WScript StdOut WriteBlankLines 1 WScript StdOut Write c WScript StdOut WriteBlankLines 1 adoRst MoveNext Next WScript StdOut Write adoRst RecordCount WScript StdOut WriteBlankLines 1 adoRst Close ADO NET Examples using Svstem using Svstem Text using Svstem Data using Svstem Data Common using System Data OleDb namespace Open class Program static void Main string args IDbConnection sConnection null IDbCommand sCommand null IDataReader sDataReader null This indicates to specify the connection string Application Program Interface Users Manual 80 Examples sConnection new OleDbConnection Provider Altibase OLEDB DSN args 0 trv sConnection Open This indicates to access to DB Console WriteLine Connection Success sCommand sConnection CreateCommand Console WritelLine Creat
5. Program cs v X 35 Attibase Data Altibaseclient Test Connection Test v 59 Maintsting args v ConsoleApplicationi 1 ESME ConsoleApplicationi i X zij Properties TE 43 System System Data NET COM Zege 07 gen Nes me System Xml Program cs OP m SE EL OSHA BS HAS YS Bu P Locate and register Altibase Data AltibaseClient dll in the lib directory under the Altibase installation directory The Altibase installation directory can be found in the environment variable 96ALTIBASE HOME Build a project and execute the created executable file Binding Array ALTIBASE NET Data Provider can bind array to the parameter It has become much faster because it executes several arrays with less network cost than typical method and supports not output and input output parameter but input parameter currently Seguential order is as follows for binding array 1 Vou should declare all variables for binding arrav Arrav size should be greater than ArravBind Count value of AltibaseCommand class Vou should bind arraved variables to the parameter If column has char varchar and blob types you should specify ArrayBindSize of AltibaseParameter class as the largest size in array elements You should set ArrayBindCount value of AltibaseCommand class ex You may insert 100 values of ArrayBindCount at a time ArrayBindCount 100 53 NET Data Provider Using N
6. Switches a transaction branch to the suspended state and end it This transaction branch can be executed by xa_start TMSUCCESS Indicates successful termination It cannot be used with TMSUSPEND or TMFAIL TMFAIL Indicates abnormal termination This transaction is specified as roll back only It cannot be used with TMSUCCES or TMSUSPEND xa_rollback Rolls back an operation that was executed for the specified transaction branch int xa_rollback XID xid int rmid long flags Flags can have the following values TMASYNC Enables xa_rollback in the async mode not supported by Altibase TMNOFLAGS It must be specified when no flag is specified Xa_prepare It should be executed before a transaction is committed or undone by the two phase commit proto col int xa_prepare XID xid int rmid long flags Flags can have the following values TMASYNC 93 XA Interface XA Application Development Not supported by Altibase TMNOFLAGS It must be specified when no flag is specified It can return the following values XA_RDONLY Indicates that a transaction does not change data A transaction executed for RM DBMS does not require commit or rollback XA_OK Indicates normal execution xa_commit Commit a specific transaction branch int xa_commit XID xid int rmid long flags Flags can have the following values TMONEPHASE It is set when one phase commit should be executed TMNOFLAGS It is set when other flags are not
7. The URL of the database to connect to The format of the URL varies by JDBC driver A Driver Classname Altibase jdbc driver ABXADataSouri The full package name of JDBC driver class used to create the physical database connections in the connection pool Note that this driver class must be in the classpath of any server to which it is deployed user 5vs A Properties The list of properties passed to the JDBC driver that are used to create physical database connections For example server dbserverl List each property value pair on a separate line Password 000000000000000000 Confirm Password 000000000000000000 The database account password used in the physical database connection You should create DataSource with created Connection Pool and then choose Services gt JDBC gt Data Sources gt Configure a new JDBC Data Source You should insert Name and JNDI Name and then check Honor Global Transaction You should insert the name of pool created prior to PoolName in the following page weblogic 8 1 See Figure 6 7 Data Source Creation New DataSource is created in Services gt JDBC gt XA Data Sources for previous version of weblogic8 1 109 XA Interface JDBC Distributed Transaction Figure 6 8 Data Source Creation workshop JDBC Data Sources gt altiTXDS Connected to localhost 7001 You are logged in as weblogic Logout OT LET Target and Deplo Notes This page allows you to de
8. All classes which includes options for distributed transaction and follows XA standard are provided as Altibase jdbc driver JTA Java Transaction API and Application Server Application processes distributed transaction through its server as the following figure Figure 6 3 Distributed Transaction Process Application Transaction Resource Application J3 Sewer Manager Adapter Application server supports XAConnection to be connected to resource Application connects to server and executes queries with obtaining connection And application server manages transaction with TM Transaction Manager TM can access to resource with resource adapter which DBMS vendor provides If resource adapter is DBMS JDBC driver package can be provided Resource adapter has 4 kinds of classes such as ResourceFactory Transactional Resource XAConnec tion and Connection XAResource ResourceFactory creates XAConnection such as XADataSourc of JDBC Spec Application server obtains XAConnection connection to DBMS from XADataSource And XAConnection obtains con nection java sql Connection instance for application and XAResource instace for TM XA Component This section discusses the XA components standard XA interface specified in the JDBC 2 0 Optional package and the ALTIBASE classes that implement them XADataSource Interface The javax sql XADataSource interface outlines factories for XA Connection
9. NAME value Example DSN 127 0 0 1 UID SYS PWD MANAGER XA NAME connl 87 XA Interface XA Interface Table 6 2 Parameters Added to XA Interface XA Parameter Description XA NAME This is connection identifier in ALTIBASE Precompiler If vou omit this value when writing a application with ALTIABSE Precompiler default connection is specified instead of this value If you specify XA NAME as conn1 you can use this value in AT clause when executing SQL statement XA LOG DIR This shows ALTIBASE XA library errors and directory logging with their informa tion If SALTIBASE HOME is specified default is SALTIBASE HOME trc Other wise default is current directory rmid writes server ID for access and you can set its value randomly If flag isn t specified you should specify it as the following TMNOFLAGS This terminates connection to specifyed RM However this returns XA_OK even if xa_close is exe cuted in this situation int xa_close char xa_info int rmid long flags xa_info is character string to write server information and its maximum length is 256byte If flag isn t specified you should specify it as the following TMNOFLAGS This starts to execute transaction branch xid is identifier of global transaction int xa_start XID xid int rmid long flags You can specify flags as the followings TMRESUME This continues to execute transaction branch suspended TMNOWAIT This returns
10. boolean supportsGetGeneratedKeys O boolean supportsGroupBy O boolean supportsGroupByBeyondSelect O boolean supportsGroupByUnrelated O boolean supportsintegritvEnhancementracilitv O boolean supportsLikeEscapeClause O boolean supportsLimitedOuterJoins O boolean supportsMinimumSQLGrammar O 17 JDBC JDBC 2 1 Core API and JDBC 2 0 Optional Package API Return Tvpe Function Name Support boolean supportsMixedCaseldentifiers O boolean supportsMixedCaseQuotedidentifiers O boolean supportsMultipleOpenResults O boolean supportsMultipleResultSets O boolean supportsMultipleTransactions O boolean supportsNamedParameters O boolean supportsNonNullableColumns O boolean SupportsOpenCursorsAcrossCommit O boolean supportsOpenCursorsAcrossRollback O boolean supportsOpenStatementsAcrossCommit O boolean supportsOpenStatementsAcrossRollback O boolean supportsOrderByUnrelated O boolean supportsOuterJoins O boolean supportsPositionedDelete O boolean supportsPositionedUpdate O boolean supportsResultSetConcurrency int type int concur O rency boolean supportsResultSetHoldability int holdability O boolean supportsResultSetType int type O boolean supportsSavepoints O boolean supportsSchemasinDataManipulation O boolean supportsSchemasinindexDefinitions O boolean supportsSchemasinPrivilegeDefinitions O boolea
11. invalid password is error code returned by ALTIBASE server In doubt Transaction Process TM recognizes problem and provides functionality to recover in doubt transaction automatically if in doubt or pending transaction occurs RM awaits until it is recovered and receive a commit deci sion automatically while locking prepared resource DBA should process transaction properly if other transaction requires data locked by in doubt trans action or the problem hasn t been correncted ALTIBASE provides performance view This enables you to search for the state of in dount transaction for processing in doubt transaction Refer to Administrator s Manual for details about VSDBA 2PC PENDING DBA can compulsorily commit or rollback transaction as follows to process it properly COMMIT FORCE global tx id ROLLBACK FORCE global tx id Application Program Interface Users Manual 116 How to Solve Problems of Application Using XA Example Vou should check in doubt trasaction and commit transaction randomiv iSQL gt select From v dba 2pc pending LOCAL TRAN ID GLOBAL TX ID 9280 69 FAEDFAED 00000001 21315 69 FAEDFAED 00000002 2 rows selected iSOL commit force 69 FAEDFAED 00000002 Commit force success Heuristic Transaction Check You can check information of heuristic transaction if it occurs Heuristic transaction denotes that RM itself makes a commit or rollback decision if in doubt transac tion can t receive command such as
12. lt DataSourceClassName gt Alti base jdbc driver ABConnectionPoolDataSource lt DataSourceClassName gt lt DatabaseName gt mydb lt DatabaseName gt lt User gt SYS lt User gt 9 JDBC Connection Pool Configuration lt Password gt MANAGER lt Password gt lt PortNumber gt 20300 lt PortNumber gt lt ServerName gt 192 168 1 1 lt ServerName gt lt Sets the custom property gt lt DataSourceType gt Connect ionPoolDataSource lt DataSourceType gt lt Sets the connection pool gt lt ConnectionPool gt lt MinPoolSize gt 4 lt MinPoolSize gt lt InitialPoolSize gt 4 lt InitialPoolSize gt lt MaxPoolSize gt 20 lt MaxPoolSize gt lt PropertyCycle gt 1 lt PropertyCycle gt lt Idle connection check interval gt lt MaxIdleTime gt 300 lt MaxIdleTime gt lt ResizingPeriod gt 60 lt ResizingPeriod gt lt Max DB operation time gt lt OperationTimeout gt 500 lt OperationTimeout gt lt ConnectionPool gt lt Database gt lt DataSource gt Application Program Interface Users Manual 10 JDBC 2 1 Core API and JDBC 2 0 Optional Package API JDBC 2 1 Core API and JDBC 2 0 Optional Package API Functions currently supported by Altibase JDBC functions to be supported in the future and unsup ported functions are described here by the JDBC version and package JDBC 3 0 API java sql package JDBC core API javax sql package gt JDBC Optional Package API JDBC 3 0 API includes al
13. please refer to PHP official site as follows http php morva net manual en index php Sample Test lt SYSTEM DSN USER_ID USER_PASSWORD conn odbc_connect Altibase SYS MANAGER if Sconn direct execution echo now i create table ti id integer name char 20 lt br gt odbc exec conn drop table t1 odbc exec conn create table ti id integer name char 20 prepare execution echo now i insert into tl value 100 Lee lt br gt stmt odbc prepare conn insert into ti values SInsert array 100 Lee if odbc execute stmt amp Insert echo error single selection Sres odbc do conn select id name sysdate from T1 odbc fetch row res SID odbc result res 1 SNAME odbc result res 2 SDATE odbc result res 3 echo id SID name SNAME datetime SDATE lt br gt odbc_close conn 25 41 PHP Interface PHP Functions for ODBC Connectivity Application Program Interface Users Manual 42 3 PERL DBD DBI This chapter describes PERL DBD DBI and PERL package installation and Altibase DBD installation to use PERL DBD DBI and how to verifv Altibase DBD 43 PERL DBD DBI Overview of PERL DBD DBI Overview of PERL DBD DBI DBI is the database API written in the form of a PERL5 module This module defines a series of meth ods and attributes concerning the database in which DBD Database Driver i
14. 12 Jif S eee os en oe Tea bind parameters jp E E at ho N EA ATI cmd CommandText insert into t1 values AltibaseParameter prml new AltibaseParameter c1 DbType Int32 prml Direction ParameterDirection Input prml Value cl AltibaseParameter prm2 new AltibaseParameter c2 DbType AnsiString prm2 Direction ParameterDirection Input prm2 Value c2 prm2 ArrayBindSize 12 max element size in bytes Application Program Interface Users Manual 54 Using NET Data Provider cmd Parameters Add prml cmd Parameters Add prm2 EA LE LE eee Soh to nr execute cre cmd ArrayBindCount arravBindCount cmd ExecuteNonQuery IDataReader sDataReader null cmd Parameters Clear cmd CommandText select from t1 sDataReader cmd ExecuteReader while sDataReader Read for int i 0 i lt sDataReader FieldCount i Console Write sDataReader GetValue i Console WriteLine sDataReader Close con Close con Dispose Declaration Declare Altibase Data Provider classes for use as in the below using Altibase Data AltibaseClient Transaction Process You can process transaction with interface provided by ADO NET In this way you should use AltibaseConnection BeginTransaction and AltibaseTransaction AltibaseConnection sConn new AltibaseConnection sConnStr sConn Open Transaction starts Alt
15. Application SerVet AE N EE 108 Exampl L ra PR 112 How to Solve Problems of Application Using XA meesseenenzznnenzannnnzzzonanzzjnnanzznnnzzzntnzzzantnzztezzzzzntnnzznznzzzntezzzntnszznnnzzzntnnzzzntnzz 116 XA Tracking Information Check asd e erin ea e ede ete hade 116 In doubt Transaction Processen een ln le 116 Heuristi Transaction Check snee NI AEK K RR amd maas a n len 117 Preface About This Manual About This Manual This manual describes how to use Altibase API Target Users This manual could be useful for the following Altibase users Database administrators Application designers Programmers Before reading this manual understanding of following background knowledge is recommended Basic knowledge required for computers operating systems and operating system command Experience in using the relational database or understanding of the database concepts Computer programming experience Software Environment This manual has been prepared assuming Altibase 5 3 1 will be used as the database server Organization This manual has been organized as follows Chapter 1 JDBC This chapter briefly describes JDBC installation using JDBC to connect to Altibase solution for Korean language set problem connection pool configuration and JDBC API Chapter 2 PHP Interface This chapter describes how to create a PHP module at ext in PHP and interface with Altibase Chapter 3 PERL DBD DBI This chapter descri
16. Data Provider type Altibase Data AltibaseClient AltibaseFactory 59 NET Data Provider Interface Setting for NET Data Provider Altibase Data AltibaseClient gt lt DbProviderFactories gt lt system data gt lt configuration gt ALTIBASE doesn t support interfaces depending on the version of ADO NET as follows All unsup ported components occur NotimplementedException Class Identification Component AltibaseConnection M ChangeDatabase M Clone P Database AltibaseCommand M Cancel M Clone P CommandTimeout P CommandType AltibaseDataReader M GetData P Depth AltibaseParameter M Clone AltibaseParameterCollection M AddRange AltibaseDataReader Depth alwavs returns 0 ADO NET 2 0 also doesn t support interfaces which ADO NET 1 X doesn t Class Identification Component AltibaseFactorv CreateDataSourceEnumerator CreatePermission Application Program Interface Users Manual 60 Interface Setting for NET Data Provider Class Identification Component AltibaseConnection M EnlistTransaction Transaction transcation P DataSource P ServerVersion AltibaseDataReader M GetDbDataReader M GetProviderSpecificFieldType M GetProviderSpecificValue M GetProviderSpecificValues P HasRows P VisibleFieldCount AltibaseDataAdapter M AddToBatch IDbCommand command M CrearBatch
17. M ExecuteBatch M GetBatchedParameter M GetBatchedRecordsAffected int commandl dentifier out int recordsAffected out Excep tion error M InitializeBatching M TerminateBatching AltibaseParameter M ResetDbType AltibaseDataSourceEnumera A tor AltibasePermission A AltibasePermissionAttribute When the class is inherited that method must be implemented or the inheriting class becomes abstract as well This method allows you to use basic method The following mem bers support basic implementation CreateCommandBuilder CreateConnectionStringBuilder CreateDataSourceEnumerator CreatePermission GetProviderSpecificFieldType GetProviderSpecificvalue GetProviderSpecificValues VisibleFieldCount GetBatchedRecordsAffected int commandldentifier out int recordsAffected out Excep 61 NET Data Provider Interface Setting for NET Data Provider tion error Member occurs NotlmplementedException if it doesn t support basic implementation Application Program Interface Users Manual 62 NET Data Provider Example NET Data Provider Example Vou can contact ALTIBASE with AltibaseConnection and then create test goods table Vou should look up data after inserting them using Altibase Data AltibaseClient class ConnectionTest static void Main string args string sConnectionString DSN 127 0 0 1 PORT NO 20091 UID sys PWD man ager This writes host IP
18. O boolean storesLowerCaseldentifiers O boolean storesLowerCaseQuotedidentifiers O boolean storesMixedCaseldentifiers O boolean storesMixedCaseOuotedldentifiers O boolean storesUpperCaseldentifiers O boolean storesUpperCaseQuotedidentifiers O Application Program Interface Users Manual 16 JDBC 2 1 Core API and JDBC 2 0 Optional Package API Return Tvpe Function Name Support boolean supportsAlterTableWithAddColumn O boolean supportsAlterTableWithDropColumn O boolean supportsANSI92EntryLevelSQL O boolean supportsANSI92FullSQL O boolean supportsANSI92IntermediateSOL O boolean supportsBatchUpdates O boolean supportsCatalogsInDataManipulation O boolean supportsCatalogsInIndexDefinitions O boolean supportsCatalogsinPrivilegeDefinitions O boolean supportsCatalogsinProcedureCalls O boolean supportsCatalogsinTableDefinitions O boolean supportsColumnAliasing O boolean supportsConvert O boolean supportsConvert int fromType int toType O boolean supportsCoreSQLGrammar O boolean supportsCorrelatedSubqueries O boolean supportsDataDefinitionAndDataManipulationTransac O tions boolean supportsDataManipulationTransactionsOnly O boolean supportsDifferentTableCorrelationNames O boolean supportsExpressionsInOrderBy O boolean supportsExtendedSQLGrammar O boolean supportsFullOuterJoins O
19. Solution for Korean Language Set Problem sn 6 Character Set ConVetsiOn ordiri N OR ENE 6 Settings INIS Pis N OE H vauNs J 6 National Character Process rttedisieitce N EO eene 7 Data Lookup and Ghandi ii 7 Using Constant Character String EE teette ete ete eee taa ae eaa eaa e eatae een ee eee 7 Connection Pool Configuration esim A A ear 8 TOMCAT A Kasea ES 8 WebLolE6 X nnn EN Red 9 Jeus IN se ann de eneen ede ane eee ee ee ER er eenakters 9 JDBC 2 1 Core API and JDBC 2 0 Optional Package API aans nr 11 JDBC SiO ue eR 11 java sqlPackage Support Status eee Ge ea 11 javax sql package Support Status 31 javax transaction xa package Support Status 33 TA fo a L I dateerde dendert 44033 JDBC Connection Fail over 35 How it Operates 35 Example 35 Cautions 1 35 2 PHP Interface EE OE OE EE EE RE AE EE EE Ee EO 37 Additional Information on the Altibase PHP Module nn 38 Installing ODBC Manager for PHP Interface sers 39 WI OD BG anna Baneet 39 Windows ODBE ii TA 39 PHP Functions for ODBC ds Eed LO eaa eaa aa eaa eaa ana aa aa eaa aan enaa een 41 Sample Test es dte ae N RIIKAAN HER RSS he MSS EE EE es 41 3 PERL DBD DBI AS 43 Overview of dd Ee jode EE OE EE N 44 PERL Package Installation sit N EO OR OE N ED 45 PERL Package Installation Procedure sn 45 Installin Altibase DBD tertie eia N EO EN 46 Installing Altibase PERL DBD
20. XA_RETRY without a wait when xa_start is blocked TMASYNC This starts to execute transaction branch in async mode unsupported in ALTIBASE TMNOFLAGS This should be specified by default if you don t set flag Application Program Interface Users Manual 88 XA Interface TMJOIN This creates transaction connected to the existing transaction branch This terminates transaction branch int xa end XID xid int rmid long flags Vou can specifv flags as the followings TMSUSPEND This makes transaction branch suspended and then terminates it This transaction branch continues to be executed by xa start TMSUCCESS You can t set this with TMSUSPEND or TMFAIL because this denotes termination successfully TMFAIL This denotes termination abnormally This transaction is specified as roll back only You can t use this with TMSUCCES or TMSUSPENT xa_rollback This rolls back operation of transaction branch int xa_rollback XID xid int rmid long flags Flags have the followings TMASYNC This executes xa_rollback in async mode unsupported in ALTIBASE TMNOFLAGS This should be specified by default if you don t set flag You can execute this befire withdrawing or reflecting transaction in 2 phase commit protocol int xa_prepare XID xid int rmid long flags Flags have the followings TMASVNC unsupported in ALTIBASE TMNOFLAGS 89 XA Interface XA Interface Vou should set this bv default if vou don t specifv
21. address of database server contacting DSN variable and port of database server for PORT NO AltibaseConnection conn new AltibaseConnection sConnectionString try conn Open This denotes to contact database AltibaseCommand command new AltibaseCommand drop table test_goods conn try command ExecuteNonQuery This executes queries catch Exception ex command CommandText create table test goods gno char 10 gname char 20 location char 9 stock integer price numeric 10 2 command ExecuteNonQuery This executes queries command CommandText insert into test goods values A111100001 IM 300 AC0001 1000 78000 command ExecuteNonQuery This executes queries command CommandText insert into test goods values A111100002 IM 310 DD0001 100 98000 command ExecuteNonOuery This executes queries command CommandText insert into test goods values B111100001 NT H5000 AC0002 780 35800 command ExecuteNonQuery This executes queries command CommandText select from test goods AltibaseDataReader dr command ExecuteReader Console WriteLine GNO GNAME LOCATION STOCK PRICE Console Write Line N while dr Read for int i 0 i lt dr FieldCount i Console Write t o drlil This prints the retrived data Console
22. as DBMS NET Framework pro vides access methods for OLEDB SQL Server ODBC and ORACLE by default The role of the NET Framework based Data Provider is to access data sources execute commands and retrieve the results These results are processed by the developer through ADO NET DataSet classes and then applied back to the data sources The biggest advantage of the ADO NET interface is that even if Altibase is upgraded the user can continue to use Data Provider or applications without having to change them as long as ODBC driv ers for the corresponding version are available For more information on ADO NET please refer to Microsoft website http www msdn com Requriements NET Framework You should install NET Framework depending on the version of ADO NET If you use ADO NET 1 0 subsequent release from starting with version 1 1 of NET Framework should be installed If you use ADO NET 2 0 subsequent release from starting with ver sion 2 0 SP1 of ADO NET should be installed You should use suitable library for version of ADO NET because NET Data Provider pro vides library file depending on the version of ADO NET ALTIBASE CLI You should install ALTIBASE CLI library because NET Data Provider connects to database with CLI library Restriction NET Data Provider enables you to use CLI libararv with odbccli sl dll suited for system You should use NET Data Provider built for NET Framework because impleme
23. ee SOTA 78 Binder Objects si NE EH ERR SR Nae ANNO Rd rite d eR UR IE MR ARR T Er 78 ROW ele Te RR 78 Stream Objects nn N EE 79 Exam OE N n 80 ADO Example sissie tummu ma EG Ned 80 ADO NET Examples 80 6 XA Interface 83 XA Interface 84 XA Glossarv 84 XA Structure 84 XA and 2PC 85 xa switch t Structure 85 KALA ol EE EE EE EE etheen anas nala M 86 PN Ce PAC ii a vate GE ee aa 87 MA FUNCTIONS NER EE OE OE OE EE EE EG vaedende 87 XA Application Development se u 92 ODBC XA Performance Process Re ee N ee Ge Ge eb aded 92 UE feb ee MN N EO EE A Executing ODBE XA SE Re ei eni be ee A ee An Asan 96 Executing SES XA D za 97 Executing JDBC XA Se Se Ge ee aa ese 99 XA Transaction Control ss Ee te AE ra sar 100 Changing the Existing Application into TPM Application 101 XAREStrICHON ai Bessie esse se n dese ek en TAAS koe ln eend Ee EER de aula Aa ana ans 103 SOL Use ES vy ede psie AN RE N iak 103 Transaction Branch usn oriri pests kaisa avas ees Ek ee Ee Re Rees ee ede ee Ee 103 Association ele ele nomo Pent 104 inder s 104 DYNAMIC se Uile EE TEKEE REA eben eE eee ere 104 Server Sh tdOWrn xac rte HR ORE eee RE EI de Ye t tr et 104 JDBG Distributed Trarisactioli ut EE eo ee ee een EE neede 105 JTA Java Transaction API and Application Server nn 105 deel sel ER OE DE EE EE N EE OE EE ade 105 Error Handling i asa aa 108 Setting in
24. if prp2 XAResource XA OK if do commit axar2 commit xid2 false else axar2 rollback xid2 Close connections connl close conni null conn2 close conn2 null pcl close pel null pc2 close pc2 null ResultSet rset stmta executeQuery select coll from my table while rset next Svstem out printin Coll is 4 rset getInt 1 rset close rset null rset stmtb executeQuery select coll from my tab while rset next Svstem out printin Coll is rset getString 1 rset close rset null stmta close Application Program Interface Users Manual 114 JDBC Distributed Transaction stmta null stmtb close stmtb null F conna close conna null connb close connb null catch SQLException sqe sqe printStackTrace catch XAException xae Svstem out printin XA Error is 4 xae getMessage static Xid createXid int bids throws XAException byte gid new byte 1 gid 0 byte 9 bytel bid new byte 1 bid 0 byte bids byte gtrid new byte 4 byte bqual new byte 4 System arraycopy gid 0 gtrid 0 1 System arraycopy bid 0 bqual 0 1 Xid xid new XID 0x1234 gtrid bqual return xid private static void doSomeWork1 Connection conn throws SQLException String sql Statement stmt conn createStatement sql insert into my_table values 1 stmt executeUpd
25. in which the Event package was decom pressed make install Note The event module checks the protocol type when data is received and determines the length of the message It is possible to know how many bytes the buffer receives because the event sends this information after a wait In addition as there are separated threads it also enables synchronization After all it can detect which event is generated 45 PERL DBD DBI Installing Altibase DBD Installing Altibase DBD Installing Altibase PERL DBD Ensure that dlext is correct by using perl V It should be sl for HP and so for other platforms If not correct reinstall perl Install perl DBI First install the perl DBI package that is needed for perl DBD compilation Method 1 With root account perl MCPAN e shell prompt install DBI Method 2 If the above method does not work download the package via ftp compile it and then install ftp ftp nuri net pub CPAN modules bv module DBI 1 perl Makefile PL 2 make 3 make install Download and install Altibase PERL DBD Connect to data altibase com and then download the file at the following location Because perl is 32 bit in an installation system Altibase 32 bit client pack age or 32 bit server package should be installed in the system And also the environment variable SALTIBASE_HOME should be specified data download back altibase PERL DBD altibase perlDBD tar gz gzip cd altibase perlDBD
26. qualifier ALTIBASE implements javax transaction xa Xid interface with XID class in Altibase jdbc driver pack age ALTIBASE doesn t require the use of Altibase jdbc driver XID for ABXAResource calls You can use any class that implements javax transaction xa Xid interface Error Handling XA methods throw ABXAException when errors occur ABXAException class is a subclass of javax transaction xa XAException class Setting in Application Server WebLogic 1 You should insert JDBC connection information after choosing Services gt JDBC gt Connection Pools gt Configure a new JDBC Connection Pool in weblogic console See Figure 6 6 JDBC Connection Information Application Program Interface Users Manual 108 JDBC Distributed Transaction Table 6 4 Connection Information Difference between NON XA and XA NON XA XA URL jdbc Altibase ipl Iporti dbname jdbc Altibase ip port dbname Driver Classname Altibase jdbc driver AltibaseDriver Altibase jdbc driver ABXADataSource Properties User username User username Figure 6 7 JDBC Connection Information Insertion workshop JDBC Connection Pools altiXAPool Connected to localhost 7001 Youare logged in as weblogic Logout This page allows you to define the general configuration of this JDBC connection pool Name altixAPool The name of this JDBC connection pool A URL jdbc Altibase 192 168 1 31 25226
27. schemaPattern A String typeNamePattern String attributeNamePattern ResultSet getBestRowldentifier String catalog String schema O String table int scope boolean nullable ResultSet getCatalogs A String getCatalogSeparator A String getCatalogTerm A ResultSet getColumnPrivileges String catalog String schema O String table String columnNamePattern ResultSet getColumns String catalog String schemaPattern O String tableNamePattern String columnNamePattern 13 JDBC JDBC 2 1 Core API and JDBC 2 0 Optional Package API Return Tvpe Function Name Support Connection getConnection O ResultSet getCrossReference String primaryCatalog String pri marySchema String primaryTable String foreignCata log String foreignSchema String foreignTable Int getDatabaseMajorVersion O Int getDatabaseMinorVersion O String getDatabaseProductName O String getDatabaseProductVersion O int getDefaultTransactionlsolation O int getDriverMajorVersion O int getDriverMinorVersion O String getDriverName O String getDriverVersion O ResultSet getExportedKeys String catalog String schema String O table String getExtraNameCharacters A String getldentifierQuoteString ResultSet getimportedKeys String catalog String schema String O table ResultSet getindexinfo String catalog String schema String O table Boolean unique Bool
28. specified xa recover Get the xid list of the prepared transactions from the Altibase server int xa recover XID xids long count int rmid long flags It returns the number of xids recovered Specify the size of xids in the Count parameter Flags can have the following values TMNOFLAGS Get XID at the current location xa forget Have the heuristically completed transaction not managed by the Altibase server int xa forget XID xid int rmid long flags Flags can have the following values TMNOFLAGS Application Program Interface Users Manual 94 XA Application Development This value should be alwavs specified xa complete When an operation is executed in the ASVNC mode wait until the operation ends It is not sup ported by Altibase and it will always return an error message 95 XA Interface Using XA Using XA This section describes basic procedures for using ODBC SES and JDBC in XA environment Executing ODBC XA xa open Connect to the specified server SQLAllocHandle To connect to ODBC create hdbc and henv SQLSetConnectAttr Specify ODBC connection for xa connection SQLConnect Because the phvsical connection was established bv xa open no new connection is created However SOLConnect connects to the inside of ODBC and DML operations can not be per fomred without this step xa start Start a transaction branch for a specific xid do SQL Statement Execute operations such as SOLPrepare and SOLExe
29. statements is as follows You should specify NcharLiteralReplace as true You should add N in front of character string to use constant character string with national character type in SQL statements Example create table t1 c1 nvarchar 1000 Properties sProps sProps put user SYS sProps put password MANAGER sProps put NcharLiteralReplace true Connection sCon DriverManager getConnection sURL sProps Statement sStmt sCon createStatement sStmt execute insert into ti values N AB7 t ResultSet sRS sStmt executeQuery select from t1 where c1 like N JIL 7 JDBC Connection Pool Configuration Connection Pool Configuration Depending on the WAS type a connection pool can be created using a GUI interface However this section describes the configuration method that edits the configuration file only Since different WAS versions provide different configuration methods check to see if there are any differences between the versions Tomcat 4 x Assume that the jakarta commons dbcp package is used Procedure Install the jakarta commons dbcp package For more information on how to install the jakarta commons dbcp package please see http jakarta apache org When the jakarta commons dbcp package has been successfully installed the following resource should be registered in the STOMCAT HOME conf server xml file slee server xml gt lt Re
30. underlying data sources XAConnection pcl axds1 getXAConnection XAConnection pc2 axds2 getXAConnection Get the physical connections Connection connl pci getConnection Connection conn2 pc2 getConnection Get the XA resources XAResource axarl pcl getXAResource XAResource axar2 pc2 getXAResource 113 XA Interface JDBC Distributed Transaction Create the Xids With the Same Global Ids Xid xidl createXid 1 Xid xid2 createXid 2 Start the Resources axarl start xidl XAResource TMNOFLAGS axar2 start xid2 XAResource TMNOFLAGS Execute SOL operations with conn1 and conn2 doSomeWork1 conn1 doSomeWork2 conn2 END both the branches IMPORTANT axarl end xidl XAResource TMSUCCESS axar2 end xid2 XAResource TMSUCCESS Prepare the RMs int prpl axarl prepare xidl int prp2 axar2 prepare xid2 System out println Return value of prepare 1 is prpl System out println Return value of prepare 2 is prp2 boolean do_commit true if prpl XAResource XA OK prpi XAResource XA RDONLY do_commit false if prp2 XAResource XA OK prp2 XAResource XA RDONLX do_commit false System out println do commit is do commit System out println Is axarl same as axar2 7 axarl isSameRM axar2 if prpl XAResource XA OK if do commit axarl commit xidi false else axarl rollback xid1
31. 27 Clob 31 Compiling Application 51 Connection 12 Connection Pool Configuration 8 ConnectionPoolDataSource 31 D Data Type 57 DatabaseMetaData 13 DataSource 32 Driver 11 E Executing JDBC XA 99 Executing ODBC XA 96 Executing SES XA 97 I in doubt Transaction Process 116 Installing Altibase PERL DBD 46 Installing ODBC Manager for PHP Interface 39 J JAVA Application 2 JDBC 3 0 API 11 JDBC Connection Fail over 35 JDBC Distributed Transaction 105 JDBC driver 2 Jeus 2 Jeus 3 x 9 N National Character 7 O ODBC XA Performance Process 92 P PERL DBD DBI 44 PERL Package Installation 45 PHP Functions for ODBC Connectivity 41 PHP Module 38 PooledConnection 32 PreparedStatement 26 R ResultSet 19 ResultSetMetaData 24 S Sample Test 41 SavePoint 31 schema 56 Settings in JSP 6 Statement 25 T Tomcat 2 Tomcat 4 x 8 TPM Application 101 U Unix ODBC 39 Using NET Data Provider 51 Using JDBC to Connect to Altibase 3 Using XA 96 W WebLogic 2 WebLogic 6 x 9 Windows ODBC 39 X XA Applicaion Development 92 XA Data Structure 85 86 XA Functions 87 XA Interface 84 87 XA Restriction 103 XA trace 116 XA Tracking Information 116 XAConnection 32 XAConnection Interface 106 XADataSource 32 XAResource 33 Xid 33 Xid interface 108 119
32. 27 0 0 1 20300 mydb lt value gt lt parameter gt lt ResourceParams gt Append the followings in the TOMCAT HOME conf web xml file lt web xml gt lt resource ref gt lt description gt Altibase Datasource lt description gt lt res ref name gt jdbc altidb lt res ref name gt lt res type gt javax sgl DataSource lt res type gt lt res auth gt Container lt res auth gt lt resource ref gt WebLogic 6 x Create a JDBC connection pool by editing the lt JDBCConnectionPool gt element in the SWL HOME config 5DomainName config xml file ot ett tre config xml gt lt JDBCConnectionPool CapacityIncrement 5 DriverName Altibase jdbc driver AltibaseDriver lt Initial connection count gt InitialCapacity 5 lt Maximum connection count gt MaxCapacity 50 Name altiPool RefreshMinutes 10 ShrinkPeriodMinutes 15 ShrinkingEnabled true lt Set Custom Property gt Properties user SYS password MANAGER encod ing KSC5601 portNumber 20300 databaseName mydb serverName 192 168 1 1 Targets myserver TestTableName dual URL jdbc Altibase 192 168 1 1 20300 mydb gt Jeus 3 x Set the POOL by editing the DataSoruce element in the SJEUS HOME config JeusMain xml file Cheeses JeusMain xml gt lt DataSource gt lt Database gt lt Vendor gt others lt Vendor gt lt ExportName gt Alti XA DB lt ExportName gt lt Sets Data Source Class
33. ALTIBASE Application Development Application Program Interface Users Manual release 5 3 3 amp ALTIBASE PERFORMANCE SOLUTIONS ALTIBASE Application Development Application Program Interface User s Manual Release 5 3 3 Copyright 2001 2009 Altibase Corporation All rights reserved This manual contains proprietarv information of Altibase Corporation it is provided under a license agreement containing restrictions on use and disclosure and is also protected bv copvright patent and other intellectual propertv law Reverse engineering of the soft ware is prohibited Altibase Corporation 10F Daerung PostTower lI 182 13 Guro dong Guro gu Seoul 152 847 Korea Telephone 82 2 2082 1000 Fax 82 2 2082 1099 E mail support altibase com www http www altibase com Contents Preface M i About This Mandal iii Ee ete e ene AA edge KIAN LA ERR AIR Qe SAND nene RU ever ii Mead EL EE OE EE are ji Software Environment ees sa ea ii Or anizatiot EE i A ii Documentation Rule tete re ln ee eee one iii Related dat rss ne a nee ended v Online Manual RR iii tete eka m OE AEE aan Sn kansan v Altibase Welcomes Your Opinions m 1 JDBC 1 Installation 2 Checking JDBC Driver Version 52 JAVA Application 2 Tomcat 02 WebLogic 2 ER ED B SPA 2 Using JDBC to Connectto Altibase oe GE neen 3 Connection Ee ie EE N Oe ee ee Ee 3
34. Connection getConnection String username String password O int getLoginTimeout X PrintWriter getLogWriter O void setLoginTimeout int seconds X void setLogWriter PrintWriter out O Return Type Function Name Support void addConnectionEventListener ConnectionEventLis O tener listener void close Connection getConnection void removeConnectionEventListener ConnectionEventList ener listener Return Type Function Name Support XAResource getXAResource O Return Type Function Name Support int getLoginTimeout PrintWriter getLogWriter XAConnection getXAConnection O Application Program Interface Users Manual 32 JDBC 2 1 Core API and JDBC 2 0 Optional Package API Return Tvpe Function Name Support XAConnection getXAConnection String user String password O void setLoginTimeout int seconds void setLogWriter PrintWriter out O Return Type Function Name Support void commit Xid xid Boolean onePhase O void end Xid xid int flags O void forget Xid xid O int getTransactionTimeout O boolean isSameRM XAResource xares O int prepare Xid xid O Xidf recover int flag O void rollback Xid xid O boolean setTransactionTimeout int seconds X void start Xid xid int flags O Return Type Function Name Support bytel getBranchOualfier Int getFormatld bytel getGlobalTransactionid When you u
35. E lib datasource foler SJEUS HOME is the home directory of Jeus installation Application Program Interface Users Manual 2 Using JDBC to Connect to Altibase Using JDBC to Connect to Altibase Connection Sequence Loading Driver Load the Altibase JDBC driver Class forName Altibase jdbc driver AltibaseDriver Here there is no need to use the drivermanager to create and register an instance for the driver If the Class forName shown above is called it will create instatace and register automatically This process makes it possible to load the driver and connect to Altibase Connecting to a database For connection use the type of connection character string supported by the Altibase JDBC driver Connection character string format Connecting TCP IP jdbc Altibase server ip server port dbname Connecting IPC using JNI jdbc Altibase localhost port no dbname user SYS amp password MANAGER amp encod ing KSC5601 amp CONNTYPE 3 jdbc Altibase IPC port no dbname Example The following is JDBC example program to connect to a database existing as Altibase installation direcotry SALTIBASE HOME sample JDBC JdbcTest java import java util Properties import java sql class JdbcTest public static void main String args Properties props new Properties Connection con null Statement stmt null PreparedStatement pstmt null ResultSet res if args length 0 System err println Usa
36. ET Data Provider 4 Vou should execute SOL statements Restriction Vou should consider the followings when binding an arrav Valid range of ArrayBindCount is from 1 to 65535 You should specify array size to the appropri ate amount because this process can t be faster even if making array size lager Error occurs if data length of single element array is greater than the value of ArrayBindSize in case that data has char varchar and blob types If database supports nchar and nvarchar you should specify value unit of ArrayBindSize as not byte but the number of characters If data has blob type array type is object and array element is bytel Ex bvtell vari byte var2 Object var new Object 2 vari var2 Clob byte nibble bit varbit and geometry are not supported for binding an array using System using System Data using Altibase Data AltibaseClient class ArrayBind static void Main AltibaseConnection con new AltibaseConnection con ConnectionString DSN 127 0 0 1 UID sys PWD man ager NLS USE KO16KSC5601 con Open Console WriteLine Connected successfully const int arrayBindCount 3 int cl new int arrayBindCount 100 200 300 String c2 new String arrayBindCount APPLE ORANGE GRAPE AltibaseCommand cmd new AltibaseCommand cmd Connection con table info orange needs 12 bytes utf16 create table t1 ci int c2 varchar
37. IJ3SAYZE AS AA Au TM gzg dH SHAMS ANH SUS pelo EMMA ID WA If XA reports TM that AP starts occurring distributed transaction TM checks what database is the tar get of distributed transaction in RM TM creates XID for transaction branch to be executed in RM and then sends it to RM This XID starts to occur distributed transaction in database node And transactions sent from AP are regarded as those sent from XID until thev terminate After they terminate AP reprts TM that distributed transaction stops occurring TM forces RM occur ring distributed transaction with XID to make a commit or rollback XA and 2PC ALTIBASE XA Interface performs 2 phase commit functionality 2PC operation has prepare and com mit steps In prepare step as the first phase of a 2PC TM checks possibility of a commit in RM that is all data base nodes participated in occurring distributed transaction If committing the transaction RM sends a prepare message to TM Otherwise RM returns value to roll back this In commit step as the second phase of a 2PC TM awaits prepare acknowledgements If receiving them normally TM agrees for total RMs to make a commit decision However if even one RM doesn t prepare a transaction TM agrees for it to make a rollback decision xa switch tStructure The following is structure of xa switch t 85 XA Interface XA Interface ALTIBASE provides it named as altibase xa switch including informa
38. JDBC JDBC Connection Fail over Application Program Interface Users Manual 36 2 PHP Interface This chapter describes how to create a PHP module at ext in PHP and interface with Altibase 37 PHP Interface Additional Information on the Altibase PHP Module Additional Information on the Altibase PHP Module 1 The data types supported are shown below resource int bool double float string array HashTable 2 You must match the port with that of the Altibase server in db php of the sample program Application Program Interface Users Manual 38 Installing ODBC Manager for PHP Interface Installing ODBC Manager for PHP Interface This section describes procedures for installing ODBC Manager for PHP interface in Unix or Windows environment Unix ODBC In Linux or Unix environment complete the following steps to install ODBC Manger Download unixODBC It can be downloaded from the unixODBC website http www unixodbc org Install unixODBC When installing the downloaded source file to a specific location enter configure prefix path configure prefix installation path enable gui no enable drivers no make make install Configure the unixODBC environment 1 Set SODBCSYSINI as an environment variable Set the value of the SODBCSYSINI environment variable to SHOME of the user s account export ODBCSYSINI 2 Basedonthe library path and bit among environment variables add the path where unix
39. O net or you use OLE DB with inputting the server address manually you can access with the following strings Provider Altibase OLEFEDB UID sys PWD manager DSN 127 0 0 1 Alti base PORT 21132 NLS USE US7ASCII Provider Altibase OLEDB Essential Reguirements for input UID User ID PWD User Password DSN Server name registered in ODBC manager or server IP address Altibase Altibase Connection String You can use Altibase connection string when you specify connection option like CLI The format for specifying properties is as follows Altibase Property Value Property Value Property Value Each property is connected with and you may input the property values in single quotation marks The following table indicates how data type conversion is between Altibase and OLE DB Altibase OLE DB BIGINT DBTYPE 18 BIT DBTYPE BOOL BLOB Not Support BYTE DBTYPE BYTES CHAR DBTYPE STR CLOB Not Support DATE DBTYPE STR DOUBLE DBTYPE R8 FLOAT DBTYPE STR GEOMETRY Not Support INTEGER DBTYPE 14 NIBBLE Not Support 69 OLE DB Installation Altibase OLE DB NUMERIC DBTVPE STR DECIMAL DBTVPE STR REAL DBTVPE R4 SMALLINT DBTVPE 12 VARBIT DBTVPE BOOL VARCHAR DBTVPE STR OLE DB doesn t support the conversion of types such as BLOB CLOB GEOMETRY NIBBLE and etc BIT VARBIT is translated in BOOL type The following table indicates data types when t
40. ODBC Driver Manager is installed as in the below The library path can be LD LIBRARY PATH LD LIBRARY PATH 64 or SHLIB PATH based on platform In the following example unixODBC is installed at usr local odbcDriverManager32 or usr local odbcDriverManager usr local odbcDriverManager64 export LD LIBRARY PATH usr local odbcDriverManager32 lib LD LIBRARY PATH export LD LIBRARY PATH 64 usr local odbeDriverManager64 lib LD LIBRARY PATH 6 Create two files in the SODBCSYSINI path as in the below odbc ini odbcinst ini odbcinst ini should be created as an empty file with the size of 0 byte In odbc ini specify the DSN name Altibase ODBC Driver installation server address and port num ber Windows ODBC In Windows environment ODBC Manger is installed by default Therefore Altibase drivers are auto matically registered with ODBC Manger when Altibase is installed 39 PHP Interface Installing ODBC Manager for PHP Interface To register drivers manually use the odbcsetup exe program provided by Altibase To register drivers odbcsetup i To remove drivers odbcsetup u Once drivers are registered register with the system DSN manually Application Program Interface Users Manual 40 PHP Functions for ODBC Connectivity PHP Functions for ODBC Connectivity The user can use ODBC functions which you can use in PHP for interface because Altibase supports standard ODBC functions For information on them
41. RL String parameterName URL val X boolean wasNull O Return Type Function Name Support InputStream getBinaryStream O bytel getBytes long pos int length O long length O long position Blob pattern long start X long position bytel pattern long start X Application Program Interface Users Manual 30 JDBC 2 1 Core API and JDBC 2 0 Optional Package API Return Tvpe Function Name Support OutputStream setBinarvStream long pos O int setBytes long pos byte bytes O int setBytes long pos bytel bytes int offset int len O void truncate long len O Return Type Function Name Support int setString long pos String str int setString long pos String str int offset int len Return Type Function Name Support int getSavepointld String getSavepointName Altibase JDBC support status in terms of JDBC 3 0 Return Type Function Name Support int getLoginTimeout X PrintWriter getLogWriter O PooledConnection getPooledConnection O PooledConnection getPooledConnection String user String password O void setLoginTimeout int seconds X void setLogWriter PrintWriter out O 31 JDBC JDBC 2 1 Core API and JDBC 2 0 Optional Package API Return Tvpe Function Name Support Connection getConnection O
42. RO EE RE uet 46 4 NET Data Provider sees oe ss oe sae se goe ee os Sau eg Ge ee 49 INET Data Provider OVetvieW i i us Ee te ee end en eben nen 50 OVERVIEW En EE EAEE EE EE Ge IE AT 50 REgUTIEIMEN Simms ERR 50 TES dd dle AE Ee EE N N Oe GE Ee OG Oe VG N ee 50 Using NET Data Provider do Ee innen 51 Compiling Application si rte fare 51 Binding Atay i iii 53 Declaration ie ER EE ee redde eeen 55 MEE ede da tea AE 55 SCHE a a NETTA A N UA ane 56 CASS EE EE EE EE N AN sani 56 Data TYPE EE disuse hana EDD 57 Interface Setting for NET Data Provider uen 59 Interface Setting ec 59 Unsupported Interface Ee EE EE OE EE a eak 60 NET Data Provider Example 63 5 OLE DB a 65 Overview of OLE DB ttt e a 66 DiS tea lath OW ccc EUR 67 Installation and Uninstallation 67 Confirmation after Installation 2 67 Access Methods sere 68 Data Types 69 Interface 72 Enumerators 72 Data Source Objects 73 SESSIONS ran OE tereseta DEM 73 Commands i PET 74 Multiple tesults ob Jects ete D Ge ee eere en een 75 STER EE EE ON 75 MAA ED 76 are eee N cc 76 Transaction S sees ees Nasan EST VMT CENTERS g e te REOR Ye ek ge ee 77 TFansaction OPHON SE i ej ra RO ke ee ee Ge en ee Re aa 77 Eie GRA AE ER NI ttes 78 CUSTOM s Edo ERREUR ee N s 78 EITORReCOLIGQS taie EE e GE ED GE ERR EE Done GRE e FER tae ee acier LESEN
43. The getXAConnection method returns an XA Connection instance public interface XADataSource XAConnection getXAConnection throws SQLException XAConnection getXAConnection String user String password throws SQLException 105 XA Interface JDBC Distributed Transaction Altibase jdbc driver ABXADataSource implements XADataSource interface located in JDBC driver which ALTBASE provides and also extends the Altibase jdbc driver ABConnectionPoolDataSource which extends the Altibase jdbc driver DataSource so includes all the connection properties described in DataSource and ABConnectionPoolDataSource Figure 6 4 ABXADataSource Class DataSource Interface XADataSource ABConnectionPoolDataSource A l l e as mm EE di l ABXADataSource ABXADataSource class getXAConnection methods return the implementation of XAConnection instances in ABPooledConnection class You can register XA data source in JNDI XAConnection interface is the subinterface of PooledConnection and also includes getConnection close addConnectionEventListener and removeConnectionEventListener methods public interface XAConnection extends PooledConnection javax jta xa XAResource getXAResource throws SQLException x XAConnection instance encapsulates a physical connection to a database and also has the facility to produce the XAResource that will correspond to it for u
44. WriteLine catch Exception ex 63 NET Data Provider NET Data Provider Example Console WriteLine ex ToString conn Close This shuts down database Execution Results GNO GNAME LOCATION STOCK PRICE A111100001 IM 300 AC0001 1000 78000 A111100002 IM 310 DDOOO1 100 98000 B111100001 NT H5000 AC0002 780 35800 Application Program Interface Users Manual 64 OLE DB This chapter describes OLE DB which Altibase supports Vou can know how to install and delete OLE DB and how to access in variable environment such as COM ADO ADO NET and etc And vou can also know data tvpes and properties which Altibase support for OLE DB 65 OLE DB Overview of OLE DB Overview of OLE DB OLE DB Object Linking and Embedding database indicates the open interface which Microsoft makes for access to general purpose database ODBC supports common API for access to database but has limits of designing and building data based application in new wav OLE DB as the new alternative supports open database access with new functionalities OLE DB sup ports access to all tvpes of data such as relational non relational and hierarchical data with using COM based programming interface Application Program Interface Users Manual 66 Installation Installation This chapter describes installation and uninstallation of OLE DB Vou can know the confirmation to use the existing ODBC driver after OLE DB install
45. a_start in RM before executing transaction because ALTIBASE doesn t support dynamic registration You may use function of altibase_xa_switch in xa_switch_t to use functions related to XA ALTBASE uses functions in altibase_xa_switch structure to use XA function Table 6 1 XA Interface XA Interface Description xa_open This denotes to connect to RM xa_close This denotes to interrupt connection from RM xa_start This denotes to start new transaction branch or the existing one again and to be linked to specified XID xa_end This denotes to be separated from transaction branch xa_rollback This denotes to rollback transaction branch related to specified XID xa prepare This denotes to prepare for a commit of transaction branch xa commit This denotes to commit transaction branch xa_recover This shows XID list of transaction making prepare heuristic commit or heurisitc rollback decisions xa_forget This denotes to discard information of transaction branch making a heuristic completion in RM This denotes to connect to RM int xa_open char xa_info int rmid long flags xa_info is null terminated character string with server information and its maximum length is 256byte This has same format as SOLDriverConnect argument and parameters such as XA NAME and XA_LOG_DIR additionally Refer to SQLDriverConnect in ODBC User s Manual for details about other parameters NAME value NAME value
46. ake a commit or rollback decision with SQLEndTran DDL ALTIBASE XA can t use DDL because DDL SQL statements make a commit decision internally Session Property You can t change autocommit property You can execute global transaction in autocommit off mode and can t change autocommit property on this case Set Trasaction You can t use SQL statements like SET TRANSACTION READ ONLY READ WRITE ISOLATION LEVEL Connection or Disconnection with EXEC SQL Statements You can t use EXEC SQL CONNECT and EXEC SQL DISCONNECT statements for connection or discon nection in precompiler Transaction Branch Multiple application threads participate in executing one global transaction and these threads have tightly coupled or loosely coupled relationshilps Tightly coupled relationship denotes thread sharing resource 103 XA Interface XA Restriction These threads are processed as one object RM enables transaction branch not to reach a resource deadlock in tightiv coupled thread However looselv coupled thread doesn t guarantee this RM regards transaction branches including looselv coupled threads as different global trnasactions each other Relationship between XID and Thread If TM creates new value of branch qualifier in XID this thread has looselv coupled relation with other threads in same branch RM executes this thread as global transaction And if TM reuses branch qualifier of XID this thread has tightiv coupled relati
47. al String parameterName BigDecimal x X void setBinaryStream String parameterName InputStream X x int length void setBoolean String parameterName Boolean x X void setBvte String parameterName byte x X void setBytes String parameterName bytel x X void setCharacterStream String parameterName Reader X reader int length 29 JDBC JDBC 2 1 Core API and JDBC 2 0 Optional Package API Return Tvpe Function Name Support void setDate String parameterName Date x X void setDate String parameterName Date x Calendar cal X void setDouble String parameterName double x X void setFloat String parameterName float x X void setint String parameterName int x X void setLong String parameterName long x X void setNull String parameterName int sqiTvpe X void setNull String parameterName int sqlType String type X Name void setObject String parameterName Object x X void setObject String parameterName Object x int tar X getSalType void setObject String parameterName Object x int tar X getSalType int scale void setShort String parameterName short x X void setString String parameterName String x X void setTime String parameterName Time x X void setTime String parameterName Time x Calendar cal X void setTimestamp String parameterName Timestamp x X void setTimestamp String parameterName Timestamp x X Calendar cal void setU
48. arting to execute transaction and cursor should be closed before transaction commits rollbacks How to write precompiler program in case of specifying XA NAME as default connection XA NAME should not exist in character string of xa open to set default connection as follows DSN 127 0 0 1 UID SYS PWD MANAGER And queries are as follows EXEC SOL UPDATE emp SET empno 5 How to write precompiler program in case of specifying XA NAME as connection If you want to specify XA NAME as connection in precompiler KA NAME conn1 should be included in character string of xa open If you want to write program with default connection and connection in which more then one XA NAME are specified you may set the following If you specify XA NAME as conn1 and conn2 open string is as follows in TM configuration DSN 127 0 0 1 UID SYS PWD MANAGER XA NAME connl DSN 127 0 0 1 UID SYS PWD MANAGER XA NAME conn2 Application Program Interface Users Manual 98 Using XA DSN 127 0 0 1 UID SYS PWD MANAGER You can do the following in function program of application server EXEC SOL AT connl UPDATE emp SET empno 5 EXEC SQL AT conn2 UPDATE emp SET empno EXEC SQL UPDATE emp SET empno 5 Il UI Executing JDBC XA The xa classes that are defined by the Altibase jdbc driver are as in the below Altibase jdbc driver ABXADataSource Altibase jdbc driver ABXAResource Altibase jdbc driver XID The ABXADataSource class is the only one that is dire
49. ate sql stmt close private static void doSomeWork2 Connection conn throws SQLException String sql Statement stmt conn createStatement sql insert into my_tab values test stmt executeUpdate sql stmt close 115 XA Interface How to Solve Problems of Application Using XA How to Solve Problems of Application Using XA This section has focus on how to search information of svstem failure when problem occurs XA Tracking Information Check ALTIBASE XA librarv records errors and tracking informaiton in trace file Vou can check information such as error code and message if opening ths file For example if xa open fails vou can know such reasons that open string has errors or TP Manager doesn t search ALTIBASE server or fails to log on bv checking tracking information Trace File Name and Location altibase xaXA NAMEdate log XA NAME This sets XA NAME value in open string Otherwize NULL is specified data This is the date specified in trace file YYYYMMDD If environment variable is specified in SALTIBASE HOME this is created in SALTIBASE HOME trc Otherwise this is created in current directory Example 104744 19381 1 ulxXaOpen XAER RMERR ERR 4102E Invalid password 104744 is logging time HHMISS 19381 is Process ID PID and 1 is resource manager ID ulxXaOpen is moduel name XAER_RMERR is XA spec error ERR 4102E is error code returned by ALTIBASE service and
50. ate second DataSource and get connection Altibase jdbc driver DataSource ads2 new Altibase jdbc driver Data Source ads2 setUrl URL2 ads2 setUser SYS ads2 setPassword MANAGER Connection connb ads2 getConnection Prepare a statement to create the table Statement stmta conna createStatement Application Program Interface Users Manual 112 JDBC Distributed Transaction Prepare a statement to create the table Statement stmtb connb createStatement try Drop the test table stmta execute drop table mv tablet catch SQLException e Ignore an error here try Create a test table stmta execute create table my_table coll int catch SQLException e Ignore an error here too try Drop the test table stmtb execute drop table mv tab catch SQLException e Ignore an error here try Create a test table stmtb execute create table my_tab coll char 30 catch SQLException e Ignore an error here too Create XADataSource instances and set properties ABXADataSource axdsl new ABXADataSource axds1 setUrl jdbc Altibase localhost 25226 mydb axdsl setUser SYS axds1 setPassword MANAGER ABXADataSource axds2 new ABXADataSource axds2 setUrl jdbc Altibase localhost 25226 mydb axds2 setUser SYS axds2 setPassword MANAGER Get XA connections to the
51. ation and how to access in variable operation envi ronment Installation and Uninstallation Vou can install OLE DB with the following command because OLE DB isn t registered automaticallv when installing Altibase regsvr32 exe altioledb dll Use the following command to uninstall OLE DB regsvr32 exe u altioledb dll Confirmation after Installation Altibase OLE DB uses ODBC driver Therefore you may confirm whether altiodbc dll file exists in SYSTEM32 folder of WINDOWS or not Etone Data Source administrator GER User DSN System DSN File DSN Drivers Tracing Connection Pooling About System Data Sources Name 0 lt alibase 0dbc 3 ALTIBASE ODBC CM511 Remove Configure An ODBC System data source stores information about how to connect to the indicated data provider amp System data source is visible to all users on this machine including NT services OK Cancel Apply Help If the file doesn t exist you may register as the following picture because you use DSN name which is registered in ODBC manager as the access string You can register DNS name in setting manage ment tools data source 67 OLE DB Installation Altibase Connection Contig Windows DSN Name altibase_odbe host name or IP 127 0 01 Part defaul 20300 21 132 User Sys Password posee Database mydb NLS USE US7ASCI 3 Cancel Access Methods You can know access methods t
52. bes PERL DBD DBI and PERL package installation and Altibase DBD installa tion to use PERL DBD DBI and how to verify Altibase DBD Chapter 4 NET Data Provider This chapter describes how to Microsoft s ADO NET interface with Altibase DBMS Chapter 6 XA Interface This chapter introduces the data structure and functions that are needed to use the XA func tions supported by Altibase and provides basic procedures for using ODBC SES and JDBC in Application Program Interface Users Manual ji About This Manual XA environment C C Precompiler This chapter describes the rules o f this manual With understanding of this rule it is easy to search information in this manual and other manuals Rules are as follows Syntax diagram e Sample code rule This manual describes the command syntax using the diagram composed of the following elements Elements Meaning The command starts The syntax element which is not a com plete command starts with an arrow Reserved word The command continues to the next line The syntax element which is not a complete command terminates with this sym gt bol The command continues from the previous line The syntax element which is a complete command starts with this sym bol End of statement Mandatory SELECT Optional NOT iii Preface About This Manual
53. cly used by the user and the remaining classes do not need to be used by the user as they are those implement the JTA interface class 1 Create ABXADataSource ABXADataSource xaDataSource new ABXADataSource xaDataSource setUrl args 0 xaDataSource setUser SYS xaDataSource setPassword MANAGER 2 Create XAConnection Create XAConnection by calling the getXAConnection method in the XADataSource class XAConnection xaConnection xaDataSource getXAConnection SYS MAN AGER 3 Create XAResource Create XAResource by calling the getXAResource method in the XAConnection class XAResource xaResource xaConnection getXaResource 4 Create Connection Create a connection for SOL by calling the getConnection method in the XAConnection class Connection connl xaConnection getConnection 5 Execute xa functions with XAResource xa functions such as xa start and xa end can be executed with methods in the XAResource class xaResource start xid XAResource TMNOFLAGS 6 Execute SQL with the Connection object Statement stmt conn createStatement int cnt st mt executeUpdate insert into t1 values 4321 mt executeUpdate insert into t1 values 4321 99 XA Interface Using XA This section describes how to control transaction in ALTIBASE XA environment Vou can t make a commit or rollback decision with queries in each database in case of using XA librarv Instead vou should call API to start or
54. commit or rollback cause of some reasons If in doubt transaction is forced to commit this transaction becomes committed heuristically And this information is inserted into SYS XA HEURISTIC TRANS If you want to delete this information you should call xa forget after executing xa recovery or run remove xid Example If DBA commits in doubt transaction changed information is inserted into SYS XA HEURISTIC TRANS iSQL gt select From v dba 2pc pending VSDBA 2PC PENDING LOCAL TRAN ID VSDBA 2PC PENDING GLOBAL TX ID 100421 69 FAEDFAED 00000001 1 row selected iSQL gt commit force 69 FAEDFAED 00000001 Commit force success iSQL gt select from system svs xa heuristic trans SYS XA HEURISTIC TRANS FORMAT ID SVS XA HEURISTIC TRANS GLOBAL TX ID SYS XA HEURISTIC TRANS BRANCH QUALIFIER SYS XA HEURISTIC TRANS STATUS SYS XA HEURISTIC TRANS OCCUR TIME 69 FAEDFAED 00000001 1 2008 08 29 10 09 53 1 row selected ISQL gt exec remove xid 69 FAEDFAED 00000001 Execute success iSQL gt select from svstem svs xa heuristic trans SYS XA HEURISTIC TRANS FORMAT ID SVS XA HEURISTIC TRANS GLOBAL TX ID 117 XA Interface How to Solve Problems of Application Using XA SYS XA HEURISTIC TRANS STATUS SYS XA HEURISTIC TRANS OCCUR TIME No rows selected Application Program Interface Users Manual 118 Index NET Data Provider 50 A Arrav Bind 53 B Blob 30 C CallableStatement
55. cute If the Commit statement is executed the server will displav an error message xa end End a transaction branch xa prepare Prepare a transaction branch for execution xa commit Execute a transaciton SOLDisconnect Switch the internal state of ODBC to disconnected However the physical connection estab lished by xa remains as it is xa close Close the xa conenction Application Program Interface Users Manual 96 Using XA Call SQLSetConnectAttr to enable XA connection to use ODBC connection ensuring that ODBC applications can use distributed transactions Provide the following parameters to associate SQLSetConnectAttr to XA connection SOLRETURN SQLSetConnectAttr SOLHDBC hdbc SQLINTEGER fAttr SOLPOINTER vParam SQLINTEGER sLen fAttr ALTIBASE XA RMID Use XA connection for the connection specified by hdbc For more information on XA connec tion assign the following structure pointer to vParam vParam It has the rmid value that is used when a connection is established by xa_open Use the following parameter to establish a XA connection to a server without specifying rmid fAttr SQL_ATTR_ENLIST_IN_DTC or SQL_ATTR_ENLIST_IN_XA Connect the current dbc for the first XA connection The SES XA program is an application that is created with SESC in XA environment The following describes procedures for using SES XA xa open Create a xa connection If EXEC SQL CONNECT is not exe
56. cuted the SESC operation for a server results in a disconnec tion error EXEC SQL CONNECT usr IDENTIFIED BY pwd ENABLE XA RMID rmid or EXEC SQL CONNECT usr IDENTIFIED BY pwd ENABLE XA Create a SESC connection associated with xa connection Specify a host variable that stores the rmid value for the server connected by xa_open after ENABLE XA RMID to execute the connect statement If rmid is not specifed associate the cur rent connection with the first xa connection xa start If a xa transaction is not started by xa start the EXEC SQL statement will generate an error 97 XA Interface Using XA EXEC SQL DML Execute DML operations for a phvsical database xa end End a xa transaction branch xa prepare xa commit xa close Close the xa conenction to the server After xa close is executed the EXEC SQL statement dis plays an error message saying that the connection is closed The SES XA Connect Statement EXEC SQL CONNECT usr IDENTIFIED BY pwd ENABLE XA RMID rmid The usr pwd host variable is actually ignored and the xa connection for the rmid specified in the rmid host variable is used to connecto to the sesc program EXEC SQL CONNECT usr IDENTIFIED BY pwd ENABLE XA The first xa connection is used as the current connection How to write a program in xa open depending on specifying XA NAME Cursor is valid only in transaction when you write XA program In other words cursor should be open after st
57. e int scale O 19 JDBC JDBC 2 1 Core API and JDBC 2 0 Optional Package API Return Function Name Support InputStream getBinarvStream int columnindex O InputStream getBinaryStream String columnName O Blob getBlob int i O Blob getBlob String colName O boolean getBoolean int columnindex O boolean getBoolean String columnName O byte getByte int columnindex O byte getByte String columnName O bytel getBytes int columnindex O bytel getBytes String columnName O Reader getCharacterStream int columnindex O Reader getCharacterStream String columnName O Clob getClob int i X Clob getClob String colName X int getConcurrency O String getCursorName X Date getDate int columnindex O Date getDate int columnindex Calendar cal A Date getDate String columnName O Date getDate String columnName Calendar cal A double getDouble int columnindex O double getDouble String columnName O int getFetchDirection O int getFetchSize O float getFloat int columnindex O float getFloat String columnName O int getint int columnindex O int getint String columnName O long getLong int columnindex O long getLong String columnName O ResultSetMetaData getMetaData O Application Program Interface Users Manual 20 JDBC 2 1 Core API and JDBC 2 0 Optional Package API
58. e Name Support IMultipleResults ISupportErrorinfo IDBAsyncStatus X Interface Name Support lAccessor AddRefAccessor isn t sup ported IColumnsinfo O IConvertType O IParentRowset X IRowset O IRowsetlnfo GetReferencedRowset isn t supported IChapteredRowset X IColumnsinfo2 X IColumnsRowset GetColumnsRowset isn t supported IConnectionPointContainer IDBAsvnchStatus IGetRow IRowsetChange IRowsetChapterMember IRowsetCurrentindex IRowsetFind IRowsetldentity IRowsetlndex IRowsetNotify x AE AE x X X x x x 75 OLE DB Interface Interface Name Support IRowsetLocate IRowsetRefresh IRowsetResvnch IRowsetScroll IRowsetUpdate IRowsetView ISupportErrorinfo X OXX IRowsetBookmark Interface Name Support IColumnsinfo lAccessorX ISupportErrorinfo IViewChapter IViewFilter IViewRowset X XJ XJI XxX XxX XxX x IViewSort Interface Name Support lAccessor IColumnsinfo IConvertType IRowset IRowsetlndex x XxX x x x x IRowsetinfo Application Program Interface Users Manual 76 Interface Interface Name Support IRowsetChange IRowsetCurrentindex IRowsetFind IRowsetldentity IRowsetLocate IRowsetNotifv IRowsetRefr
59. eCommand Success This indiactes to specify SQL statement sCommand CommandText select from t1 sCommand CommandType CommandType Text sDataReader sCommand ExecuteReader Console WriteLine ExecuteReader Success This indicates to output data while sDataReader Read This indicates to output data as manv as columns for int i 0 i lt sDataReader FieldCount i Console WriteLine GetDataTypeName sDataReader GetDataTypeName i Console WriteLine IsDBNull sDataReader IsDBNull i Console WriteLine Value sDataReader GetValue i sDataReader Close This indicates to end the access sConnection Close Console WriteLine Close Success catch Exception e Console WriteLine e Message EE 81 OLE DB Examples Application Program Interface Users Manual 82 6 XA Interface This chapter introduces XA basic concept interface limitation and XA functions supported by ALTI BASE and also describes how to use global transaction in ODBC SES and JDBC and how to deal with problems occurred by application 83 XA Interface XA Interface XA Interface XA is a standard interface used for distributed transaction or global transaction processing speci fied bv X Open Distributed transaciton is called global transaction among svstems in more than 2 networks Svstem has resource role of transaction and TM creates and manages t
60. ean approximate int getJDBCMajorVersion O int geUDBCMinorVersion O int getMaxBinaryLiteralLength O int getMaxCatalogNameLength O int getMaxCharLiteralLength O int getMaxColumnNameLength O Int getMaxColumnsInGroupBy O Int getMaxColumnsinindex O int getMaxColumnslnOrderBy O int getMaxColumnslnSelect O int getMaxColumnslnTable O int getMaxConnections O Application Program Interface Users Manual 14 JDBC 2 1 Core API and JDBC 2 0 Optional Package API Return Tvpe Function Name Support int getMaxCursorNameLength O int getMaxindexLength O int getMaxProcedureNameLength O int getMaxRowSize O int getMaxSchemaNameLength O int getMaxStatementLength O int getMaxStatements O int getMaxTableNameLength O int getMaxTablesinSelect O int getMaxUserNameLength O String getNumericFunctions O ResultSet getPrimaryKeys String catalog String schema String O table ResultSet getProcedureColumns String catalog String sche O maPattern String procedureNamePattern String columnNamePattern ResultSet getProcedures String catalog String schemaPattern O String procedureNamePattern String getProcedureTerm O int getResultSetHoldability O ResultSet getSchemas O String getSchemaTerm O String getSearchStringEscape O String getSQLKeywords O int getSQLStateType O String getStringFunctio
61. er for weblogic env put Context INITIAL CONTEXT FACTORY jeus jndi JNSContextFactory jeus jndi jns url XA Interface JDBC Distributed Transaction UserTransaction tx UserTransaction ctx lookup java comp UserTransac tion step 3 start Transaction System out println Start Transaction tx tx begin try step 4 doing query step 4 1 get Datasource DataSource xadsl DataSource ctx lookup altiTXDS Example You can know how to implement distributed transaction by using ALTIABSE XA as the following example Start transaction branch 1 Start transaction branch 2 Execute DML operations on branch 1 Execute DML operations on branch 2 End transaction branch 1 End transaction branch 2 Prepare branch 1 Prepare branch 2 Commit branch 1 Commit branch 2 import java sql import javax sql import Altibase jdbc driver import javax transaction xa class XA4 public static void main String args throws SQLException try String URL1 jdbc Altibase localhost 25226 mydb Xou can put a database name after the sign in the connection URL String URL2 jdbc Altibase localhost 25226 mydb Create first DataSource and get connection Altibase jdbc driver DataSource adsl new Altibase jdbc driver Data Source ads1 setUrl URL1 ads1 setUser SYS ads1 setPassword MANAGER Connection conna adsl getConnection Cre
62. esh IRowsetResvnch IRowsetScroll IRowsetUpdate IRowsetView ISupportErrorinfo X XJ X X X X X X X X xi x Interface Name Support IConnectionPointContainer ITransaction ISupportErrorinfo Interface Name Support ITransactionOptions ISupportErrorinfo 77 OLE DB Interface Interface Name Support IErrorRecords O Interface Name Support ISQLErrorinfo O Interface Name Support IErrorinfo O Interface Name Support IBindResource X ICreateRow X IDBBinderProperties X IRegisterProvider X ISupportErrorinfo X Interface Name Support IColumnsinfo O Application Program Interface Users Manual 78 Interface Interface Name Support IConvertType O IGetSession O IRow GetSourceRowsetisn t sup ported IColumnsinfo2 IConnectionPointContainer ICreateRow IDBAsvnchStatus IDBCreateCommand IDBlnitialize IRowChange IRowSchemaChange IScopedOperations ISupportErrorinfo O X X X X X X X X X Interface Name Support ISequentialStream IConnectionPointContainer IDBAsvnchStatus IDBlnitialize IGetSourceRow ISupportErrorinfo IStream x o o X X x 79 OLE DB Examples
63. esource Manager RM DBMS int xa open char xa info int rmid long flags xa info is a null terminated string It has server information and its max length is 256 bytes rmid contains the ID of a server to connect to and can use any value Flags can have the following values TMNOFLAGS It must be specified when other flag is not set xa close Closes a conenction with the specified RM However if xa close is executed for the connection that is closed already XA OK will be returned int xa close char xa info int rmid long flags xa info is a string that contains server information and its max length is 256 bytes Flags can have the following values TMNOFLAGS It must be specified when other flag is not set xa start Starts a transaction branch int xa start XID xid int rmid long flags xid is an identifier for a global transaction Flags can have the following values TMRESUME Resumes the suspend transaction branch TMNOWAIT When xa start is blocked return XA RETRY without waiting TMASYNC Application Program Interface Users Manual 92 XA Application Development Starts a transaction branch in the async mode not supported by Altibase TMNOFLAGS It must be specified when no flag is specified TMJOIN Creates a transaction that is connected to a transaction branch which exists already xa_end End a transaction branch int xa_end XID xid int rmid long flags Flags can have the following values TMSUSPEND
64. etBoolean int parameterlndex Boolean x O void setByte int parameterlndex byte x O void setBytes int parameterindex bytel x O void setCharacterStream int parameterindex Reader reader O int length Application Program Interface Users Manual 26 JDBC 2 1 Core API and JDBC 2 0 Optional Package API Return Tvpe Function Name Support void setClob int i Clob x X void setDate int parameterlndex Date x O void setDate int parameterindex Date x Calendar cal X void setDouble int parameterindex double x O void setFloat int parameterindex float x O void setint int parameterlndex int x O void setLong int parameterlndex long x O void setNull int parameterindex int salType O Void setNull int paramIndex int sqlType String typeName O Void setObject int parameterIndex Object x O Void setObject int parameterlndex Object x int targetSql O Type Void setObject int parameterlndex Object x int targetSql O Type int scale void setRef int i Ref x X void setShort int parameterlndex short x O void setString int parameterlndex String x O void setTime int parameterindex Time x O void setTime int parameterindex Time x Calendar cal X void setTimestamplint parameterindex Timestamp x O void setTimestamplint parameterlndex Timestamp x Cal X endar cal void setUnicodeStream int parameterlndex InputS
65. fine the configuration for this JDBC data source Name altiTXDS The name of this JDBC data source A JNDI Name aliTXDS The JNDI path to where this JDBC data source is bound Pool Name altixAPool v The JDBC connection pool associated with this data source The connection pool you select is used to supply database connections to client applications that reguest a connection from this data source Advanced Options Show App Weblogic Application Example step 1 JNDI Lookup and get UserTransaction Object Context ctx null Hashtable env new Hashtable Parameter for weblogic env put Context INITIAL CONTEXT FACTORY weblogic jndi WLInitialContextFac tory env put Context PROVIDER URL t3 localhost 7001 env put Context SECURITY PRINCIPAL weblogic env put Context SECURITY CREDENTIALS weblogic ctx new InitialContext env System out println Context Created ctx step 2 get User Transaction Object UserTransaction tx UserTransaction ctx lookup javax transaction User Transaction step 3 start Transaction System out println Start Transaction tx tx begin try step 4 doing query step 4 1 get Datasource DataSource xadsi DataSource ctx lookup altiTXDS JEUS You should set basic setup to create JDBC data source in JEUS 1 You should choose JEUS manager resource and then select new JDBC data source creation 2 You should insert
66. flag Xa_prepare returns the followings XA_RDONLY This is returned when transaction occurrence doesn t make data changed Transaction exe cuted in RM DBMS need not commit or roll back XA_OK This is returned in case of normal execution xa commit This reflects certain transaction branch int xa commit XID xid int rmid long flags Flags have the followings TMONEPHASE Vou can set this for 1 phase commit TMNOFLAGS Vou can set this bv default when other flags aren t specified This obtains xid list of transaction at the prepare in ALTIBASE server int xa recover XID xids long count int rmid long flags This returns the number of recoverd xid Vou should set size of xids in count parameter Flags have the followings TMNOFLAGS Vou can have XID at current location This enables ALTIBASE server not to manage transaction completed heuristicallv int xa forget XID xid int rmid long flags Flags have the following TMNOFLAGS This should be alwavs specified Application Program Interface Users Manual 90 XA Interface xa complete This denotes to await until operatoin terminates in case of operation in avnc mode This is unsup ported in ALTIBASE and always returns errors 91 XA Interface XA Application Development XA Application Development ODBC XA Performance Process To use XA functions the user should use altibase xa switch functions in xa switch t construct Xa open Connects to R
67. ge java JdbeTest port no n System exit 1 String port args 0 String url jdbc Altibase 127 0 0 1 port mydb String user SYS 3 JDBC Using JDBC to Connect to Altibase String passwd MANAGER props put user user props put password passwd props put privilege sysdba This denotes access to database remotely with sysdba privilege Deploy Altibase s JDBC Driver try Class forName Altibase jdbc driver AltibaseDriver catch Exception e System err println Can t register Altibase Driver return Initialize environment try con DriverManager getConnection url props stmt con createStatement catch Exception e e printStackTrace try stmt execute DROP TABLE TESTOO1 catch SQLException se try stmt execute CREATE TABLE TESTOO01 name varchar 20 age number 3 pstmt con prepareStatement INSERT INTO TESTOO1 VALUES pstmt setString 1 Alexandr Macedon pstmt setInt 2 28 pstmt execute pstmt setString 1 Nikola Tesla pstmt setInt 2 25 pstmt execute pstmt setString 1 Frankenstein pstmt setInt 2 34 pstmt execute res stmt executeQuery SELECT FROM TEST001 Fetch all data while res next Svstem out printin Name res getString 1 Age res getInt 2 Ap
68. heir OLE DB is translated in Altibase OLE DB Altibase DBTVPE 12 SMALLINT DBTVPE 14 INTEGER DBTVPE R4 REAL DBTVPE R8 DOUBLE DBTVPE CV BIGINT DBTYPE_UI1 SMALLINT DBTVPE 11 SMALLINT DBTYPE UI2 INTEGER DBTYPE Ul4 BIGINT DBTYPE 18 BIGINT DBTYPE UI8 BIGINT DBTYPE BYTES BYTE DBTYPE STR VARCHAR DBTYPE WSTR VARCHAR DBTYPE DBDATE DATE DBTYPE DBTIME DATE DBTYPE DBTIMESTAMP DATE Application Program Interface Users Manual 70 Installation Restriction You should add N in front of character string to use constant character string with national charac ter type in SQL statemsnts 71 OLE DB Interface Interface Altibase supports OLE DB interface as follows OLEDB CoType Support Enumerators Data source objects Sessions Commands Multiple results objects Rowsets Views Indexes Transactions Transaction options Error Custom errors Error records Binder objects Row objects xi o x oOo o x x xixo o o o Ol x Stream objects Interface Name Support IParseDisplayName ISourcesRowset IDBlnitialize IDBProperties XIXIXI X X ISupportErrorinfo Application Program Interface Users Manual 72 Interface Interface Name Support IDBCreateSession IDBlnitialize IDBProperties IPersist ICon
69. ibaseTransaction sTrans sConn BeginTransaction AltibaseCommand sCmd sConn CreateCommand Transaction Process TODO Transaction terminate s sTrans Commit 55 NET Data Provider Using NET Data Provider ALTIBASE supports GetSchema method being used to return general schemas such as Metadata Collections DataSourcelnformation DataTypes Restrictions and ReservedWords and schema con taining information of meta table additionally as follows Table 4 1 Schema of Meta Table supported by ALTIBASE Schema Meta Table Description Users SYS USERS User meta table Tables SYS TABLES Table meta table Views SYS VIEWS View meta table Sequences VSSEQ Sequence information Synonyms SYS SYNONYMS Synonym meta table Indexes SYS INDICES Meta table containing index information Columns SYS COLUMNS _ Column meta table Constraints SYS CONSTRAINTS Meta table containing con straint Procedures SYS PROCEDURES Meta table of stored proce dure and function ProcedureParameters SYS PROC PARAS Information of parameter used in stored procedure For more information of schemas supported by ALTIBASE see data dictionary of Administrator s Manual Altibase NET Data Provider provides functions for database connection query execution and result browsing and it uses four types of class in Table 4 2 to perform these functions For information on the functionality of sub method
70. l previous JDBC API versions JDBC 2 1 core API JDBC 2 0 Optional Package API The above two combined are called JDBC 2 0 API JDBC 1 2 API JDBC 1 0 API java sql Package Support Status Altibase JDBC Driver support status in terms of JDBC 3 0 Driver Return Function Name Support boolean acceptsURL String url O Connection connect String url Properties info O Int getMajorversion O Int getMinorVersion O DriverPropertylnfo getPropertylnfo String url Properties info O boolean jdbcCompliant O 11 JDBC JDBC 2 1 Core API and JDBC 2 0 Optional Package API Return Function Name Support Void clearWarnings O Void close O Void commit O Statement createStatement O Statement createStatement int resultSetType int resultSetConcur O rency Statement createStatement int resultSetType int resultSetConcur X rency int resultSetHoldability Boolean getAutoCommit O String getCatalog Int getHoldability X DatabaseMetaData getMetaData O Int getTransactionlsolation O Map getTypeMap O SQLWarning getWarnings O Boolean isClosed O Boolean isReadOnly O String nativeSQL String sql O CallableStatement prepareCall String sql O CallableStatement prepareCall String sql int resultSetType int result X SetConcurrency CallableStatement prepareCall String sql int resultSetType int re
71. lumn names file names etc Capital letters Elements provided by the system or DESC SYSTEM SYS INDICES keyword appeared in the syntax Related data For more detailed information see the following document list Altibase Administration Installation User s Manual Altibase Administration Administrator s Manual Altibase Administration Replication User s Manual Altibase Application Development Precompiler User s Manual Altibase Application Development ODBC User s Manual Altibase Tools iSQL User s Manual Altibase Tools Utilities User s Manual ALTIBAE Message Error Message Reference Online Manual Korean and English versions of on line manuals PDF or HTML are available from Altibase Download Center http atc altibase com i Altibase Welcomes Vour Opinionsl Please send us vour comments and suggestions regarding this manual Vour comments and sugges tions are important and thev mav be used to improve future versions of the manual When vou send vour feedback please make sure to include the following information The name and version of the manual in use Vour comments or suggestions regarding the manual Vour name address and phone number v Preface About This Manual Please send vour e mail to the following address support altibase com This address is intended to report any errors or omissions discovered in the manual When you need an immediate assistance regarding technical issues please co
72. n supportsSchemasinProcedurecalls O boolean supportsSchemasinTableDefinitions O boolean supportsSelectForUpdate O boolean supportsStatementPooling O boolean supportsStoredProcedures O boolean supportsSubqueriesInComparisons O boolean supportsSubqueriesinexists O boolean supportsSubqueriesinins O Application Program Interface Users Manual 18 JDBC 2 1 Core API and JDBC 2 0 Optional Package API Return Tvpe Function Name Support boolean supportsSubqueriesInQuantifieds O boolean supportsTableCorrelationNames O boolean supportsTransactionlsolationLevel int level O boolean supportsTransactions O boolean supportsUnion O boolean supportsUnionAll O boolean updatesAreDetected int type O boolean usesLocalFilePerTable O boolean usesLocalFiles O Return Function Name Support boolean absolute int row O void afterLast O void beforeFirst O void cancelRowUpdates X void clearWarnings O void close O void deleteRow X int findColumn String columnName O boolean first O Array getArray int i X Array getArray String colName X InputStream getAsciiStream int columnindex O InputStream getAsciiStream String columnName O BigDecimal getBigDecimal int columnindex O BigDecimal getBigDecimal int columnindex int scale O BigDecimal getBigDecimal String columnName O BigDecimal getBigDecimal String columnNam
73. nectionPointContainer IDBAsynchNotify IDBAsynchStatus IDBDataSourceAdmin IDBInfo IObjectAccessControl IPersistFile ISecuritvinfo ISupportErrorinfo ITrusteeAdmin ITrusteeGroupAdmin x KORREK KORREK X X OI Or Ol o Interface Name Support IGetDataSource IOpenRowset ISessionProperties lAlterindex lAlterTable IBindResource IConnectionPointContainer ICreateRow X xI XxX xixlior rorlo 73 OLE DB Interface Interface Name Support IDBCreateCommand IDBSchemaRowset IlhdexDefinition ISupportErrorinfo ITableCreation ITableDefinition XIXJOJXjJOojo ITableDefinitionWithConstraints X ITransaction Abort isn t supported GetTransactionInfoisn t supported ITransactionJoin X ITransactionLocal GetOptionsObjectisn t sup ported ITransactionObject X Interface Name Support lAccessor AddRefAccessor isn t sup ported IColumnsinfo O ICommand Cancel isn t supported ICommandProperties ICommandText IConvertType IColumnsRowset ICommandPersist ICommandPrepare ICommandWithParameters ISupportErrorinfo ICommandStream Application Program Interface Users Manual 74 xjojojojlxixjiorojro Interface Interfac
74. ns O ResultSet getSuperTables String catalog String schemaPattern X String tableNamePattern ResultSet getSuperTypes String catalog String schemaPattern X String typeNamePattern String getSystemFunctions O ResultSet getTablePrivileges String catalog String schemaPat tern String tableNamePattern 15 JDBC JDBC 2 1 Core API and JDBC 2 0 Optional Package API Return Tvpe Function Name Support ResultSet getTables String catalog String schemaPattern String O tableNamePattern String types ResultSet getTableTypes O String getTimeDateFunctions O ResultSet getTypelnfo O ResultSet getUDTs String catalog String schemaPattern String O typeNamePattern int types String getURL String getUserName ResultSet getVersionColumns String catalog String schema X String table boolean insertsAreDetected int type O boolean isCatalogAtStart O boolean isReadOnly O boolean locatorsUpdateCopy O boolean nullPlusNonNulllsNull O boolean nullsAreSortedAtEnd O boolean nullsAreSortedAtStart O boolean nullsAreSortedHigh O boolean nullsAreSortedLow O boolean othersDeletesAreVisible int type O boolean othersinsertsAreVisible int type O boolean othersUpdatesAreVisible int type O boolean ownDeletesAreVisible int type O boolean owninsertsAreVisible int type O boolean ownUpdatesAreVisible int type
75. ntact Altibase Customer Support Cen ter We always appreciate your comments and suggestions Application Program Interface Users Manual vi JDBC This chapter briefly describes JDBC installation using JDBC to connect to Altibase solution for Korean language set problem connection pool configuration and JDBC API 1 JDBC Installation Installation Download the JDBC driver Altibase jar from the Altibase website www altibase com 2 Copy to the resource directory of each WAS If necessary edit the configuration file for each WAS Checking JDBC Driver Version Following shows how to check the driver version of the currently used JDBC and JDK shell gt java jar SALTIBASE HOME lib Altibase jar JDBC Driver Info Altibase Ver 5 3 1 0 for JavaVM v1 4 CMP 5 5 1 SRevi sion 14502 JAVA Application Append the pathe of Altibase jar to the CLASSPATH environment like following example CLASSPATH SCLASSPATH usr local lib Altibase jar export CLASSPATH Tomcat If you copy the Altibase jar file in the STOMCAT HOME common lib directory you will be able to use the Altibase JDBC driver in all Web Applications STOMCAT_HOME is the home directory of Tomcat installation WebLogic Copy the Altibase jar file to the WL_HOME lib folder Add the path of Altibase jar to CLASSPATH of startWebLogic sh SWL HOME is the home directory of Weblogic installation Jeus Copy the Altibase jar file to the SJEUS_HOM
76. ntation is differ ent depending on the version of NET Framework ColumnName performs case sensitive in DataReader and CommandBuilder If you don t place column name inside quotation maks when creating table column name is written in capital letters In this case you should write column name in capital letter for correct value Data loss can occur when you retrieve data whose size is greater than the value of System Dec imal because data type becomes specified as decimal NET when you retrieve data which has NUMBER NUMERIC FLOATand DECIMAL types by using DataReader GetValue Application Program Interface Users Manual 50 Using NET Data Provider Using NET Data Provider Altibase NET Data Provider can be found in the lib folder under the Altibase installation directory environment variable ALTIBASE_HOME The path is as follows SALTIBASE HOME 1ibVAltibase Data AltibaseClient dll Compiling Application The user can use Altibase NET Data Provider to compile applications in one of two ways Compilation with Command To compile codes with a command refer to DLL as in the below csc r ALTIBASE HOMES lib Altibase Data AltibaseClient dll program name cs Compilation in IDE Envrionment The following example shows how NET Data Provider is registered in IDE environment Figure 4 1 Opening New Project Windows 8 2298 sus 2012212 Windows HES 21012210 MB SE 2228 ADJE SX Bereta Reports 88 28214 Masa S
77. o use OLE DB in variable environment such as COM ADO ADO net and etc as follows You can use connection strings which Altibase driver supports for access Access at COM All types of data access are available with using COM based programming interface OLE DB is used through data provider with interface altioledb dll to use COM based OLE DB efficiently CLSIDFromProgID OLESTR Altibase OLEDB amp clsid This outputs the value of CLSID as the name of OLE DB CoCreateInstance clsid NULL CLSCTX INPROC SERVER IID IDBInitialize void amp pIDBInitialize InitProperties dwPropertyID DBPROP INIT DATASOURCE InitProperties vValue vt VT BSTR InitProperties vValue bstrVal SysAllocString LPOLESTR L altibase odbc This indicates DSN name registered in ODBC manager Access at ADO Input Altibase OLEDB in Altibase provider as follows to access to the registered DSN altibase odbc in ODBC manager at ADO ADO net Dim con As New ADODB Connection con ConnectionString Provider Altibase OLEDB DSN altibase odbc con Open Access at ADO net using System Data OleDb This indicates to use oledb Application Program Interface Users Manual 68 Installation OleDbConnection connection new OleDbConnection connection ConnectionString Provider Altibase OLEDB DSN altibase odbc connection Open This indicates to access However if DSN isn t registered in ODBC manager in case of accessing at ADO AD
78. ob x X void updateClob String columnName Clob x X void updateDate int columnindex Date x X void updateDate String columnName Date x X void updateDouble int columnindex double x X void updateDouble String columnName double x X void updateFloat int columnindex float x X void updateFloat String columnName float x X void updatelnt int columnindex int x X void updatelnt String columnName int x X void updateLong int columnindex long x X void updateLong String columnName long x X void updateNull int columnindex X void updateNull String columnName X void updateObject int columnindex Object x X void updateObject int columnindex Object x int scale X void updateObject String columnName Object x X void updateObject String columnName Object x int scale X void updateRef int columnindex Ref x X void updateRef String columnName Ref x X void updateRow X void updateShort int columnindex short x X void updateShort String columnName short x X void updateString int columnindex String x X void updatestring String columnName String x X void updateTime int columnindex Time x X void updateTime String columnName Time x X void updateTimestamp int columnindex Timestamp x X 23 JDBC JDBC 2 1 Core API and JDBC 2 0 Optional Package API Return Function Name Support void updateTimestamp String columnName Timestam
79. of application Environment setting file is in xml file format You should add information of NET Data Provider in subcategory of system data DbProviderFactories How to register the setting file of NET Framework Setting file of NET Framework is saved in its subcategory CONFIG folder as machine config NET Framework is tipycally installed in windir Microsoft NET Framework for each its version The location of setting file in NET Framework 2 0 is as follows c Windows Microsoft NET Framework v2 0 50727 CONFIG machine config You should open machine config and add information of NET Data Provider to subcategory of svs tem data DbProviderFactories as follows add name Altibase Data Provider invariant Altibase Data AltibaseClient description Altibase Data Provider type Altibase Data AltibaseClient AltibaseFactory Altibase Data AltibaseClient gt How to use environment setting file of application Environment setting file of application is saved as the name of executable file config in the direc tory where executable file exists For example environment setting file of application is AltiT est exe cofig if executable file is AltiTest exe lt xml version 1 0 encoding utf 8 723 configuration lt system data gt lt DbProviderFactories gt lt remove invariant Altibase Data AltibaseClient gt lt add name Altibase Data Provider invariant Altibase Data AltibaseClient description Altibase
80. on with other threads sharing this branch RN regards these tightly coupled threads as one object and guarantees that tightly coupled threads are not in resource deadlock each other Association Migration ALTIBASE doesn t support association migration TM restarts to execute suspended branch associ ated with other branches Async Call ALTIBASE doesn t support async XA call Dynamic Registration ALTIBASE server doesn t support dynamic registration but static registeration DYnamic registeration denotes that RM registers global transaction in TM before starting to execute global transaction RM should know when transaction starts to be excuted by calling xa_start for static registration Server Shutdown If prepared transaction exists during shutdown abort or abnormal shutdown recovery is applied to this upon startup And then you can execute this with xa_recover If prepared transaction exists during immediate shutdown or normal shutdown ALTIBASE shuts down server by aborting a transaction and then recovery is applied to prepared transaction In this event prepared transaction is simply left in the state that it was in Otherwise ALTIBASE shuts down server normally without recovery upon startup Application Program Interface Users Manual 104 JDBC Distributed Transaction JDBC Distributed Transaction ALTIBASE JDBC to support distributed transaction follows connection pooling and OpenXA standard in JDBC 2 0 extension API
81. p x boolean wasNull O Return Type Function Name Support String getCatalogName int column A String getColumnClassName int column O Int getColumnCount O int getColumnDisplaySize int column O String getColumnLabel int column O String getColumnName int column O int getColumnTypelint column O String getColumnTypeName int column O int getPrecision int column O int getScale int column O String getSchemaName int column O String getTableName int column O boolean isAutolncrement int column O boolean isCaseSensitive int column O boolean isCurrency int column O boolean isDefinitelyWritable int column O int isNullable int column O boolean isReadOnly int column O boolean isSearchable int column O boolean isSigned int column O boolean isWritable int column O Application Program Interface Users Manual 24 JDBC 2 1 Core API and JDBC 2 0 Optional Package API Return Tvpe Function Name Support void addBatch String sql O void cancel O void clearBatch O void clearWarnings O void close O boolean execute String sql O boolean execute String sql int autoGeneratedKeys A boolean execute String sql inti columnindexes X boolean execute String sql String columnNames X inti executeBatch O ResultSet executeQuery String sql O int executeUpdate String sql O int executeUpdate String sql int a
82. plication Program Interface Users Manual 4 Finalize process stmt close pstmt close con close catch Exception e e printStackTrace How to execute the example program is as follows javac JdbcTest java java JdbcTest 20300 Name Alexandr Macedon Age 28 Name Nikola Tesla Age 25 Name Frankenstein Age 34 Using JDBC to Connect to Altibase JDBC Solution for Korean Language Set Problem Solution for Korean Language Set Problem Character Set Conversion ALTIBASE JBDC obtains information of database character set in ALTIBASE server when connecting to application and then converts Java string of UTF16 to database character set UTF16 Java String lt gt Altibase Server DB Character Set Settings in JSP On the top of JSP page add lt page contentType text html charset euc kr gt To be normally performed in the JSP and Servlet progam Korean character executes request setCharacterEncoding KSC5601 Application Program Interface Users Manual 6 National Character Process National Character Process This section describes how to use national characters such as NCHAR and NVARCHAR in JDBC Data Lookup and Change You can look up and change NCAHR and NVARCHAR typed data by using JDBC with getString and setString like CHAR and VARCHAR tvped data Using Constant Character String How to use constant character string with national character tvpe in SQL
83. pload the data by using setByte a data size is under constraint 33 JDBC JDBC 2 1 Core API and JDBC 2 0 Optional Package API When you upload the data over 64KB you should upload by using stream of BLOB Application Program Interface Users Manual 34 JDBC Connection Fail over JDBC Connection Fail over When vour operating database svstem is failed if vou have multiple operating database servers vou can make Altibase move vour connections to an other server How it Operates The ABConnectionPoolDataSource class provides connection fail over functionality If you specify the URL of other servers using the class named ABConnectionPoolDataSource String aURL Alti base generates connection pool using the server URL list A system failure occurred Altibase detacts it and tries to connect to the next server in the URL list Example String serverList new String 2 serverList 0 jdbc Altibase localhost 20556 mydb user SYS amp pass WOrd MANAGER amp CONNTYPE 1 serverList 1 jdbc Altibase localhost 20557 mydb user SYS amp pass word MANAGER amp CONNTYPE 1 ABConnectionPoolDataSource pool new ABConnectionPoolDataSource serverList Cautions When Altibase moves connections associated transactions are rollbacked automatically If Altibase failed to connect to the last server in the reservered URI list it retries to conect to the first server once if it fail again Altibase return connection error 35
84. ransaction for all functions related to this resource In other words XA enables distributed application to share resource provided bv mul tiple database servers or execute transaction globallv XA is useful for application processing transaction in more than one database XA Glossarv e Global Transaction This denotes total transactions processed by XA and is called distributed transaction Transaction Branch Each of the RM s internal units of work in support of a global transaction is part of exactly transaction branch There are a one to one correlation between one transaction branch and one XID transaction ID of XA In doubt Transaction This denotes transaction branch until RM is reported at the prepare before receiving a commit or rollback and is called pending transaction Heuristic Transaction An heuristic completion occurs when a resource makes a unilateral decision during the com pletion stage of a distributed transaction to commit or rollback updates Network failures or transaction timeouts are possible causes for heuristic completion such as heuristic commit and heuristic rollback XA Structure XA structure is composed of AP Application Program TM Transaction Manager and RM Resource Manager Application Program Interface Users Manual 84 XA Interface Figure 6 1 XA Structure Native TX Interface l Interface TM XA Interface AP AS ASA ACE STS TH St SAAM RM dEJ
85. s created This driver can also be obtained through the PERL5 module DBI serves as a switch between several DBDs in an application program Actually it is DBD that communicates with the database The driver of Altibase is called DBD altibase These methods and attributes are divided into database attributes amp meth ods and statement attributes amp methods Altibase DBD A EE SA Pit Application Program Interface Users Manual 44 PERL Package Installation PERL Package Installation PERL Package Installation Procedure 1 Download the PERL package according to the necessary server and version Example for Sun http www sunfreeware com a Decompress the package ex perl 5 8 5 tar gz in any directory gzip cd perl 5 8 5 tar gz tar xvf Execute configure in the directory in which the perl package was decompressed configure Execute make in the directory in which the perl package was decompressed make Install as the root account in the directory in which the perl package was decompressed make install 2 Download the event package ex Event 1 00 tar gz to install the Event module a Decompress Event 1 00 tar gz in any directory gzip cd Event 1 00 tar gz tar xvf Execute configure in the directory in which the perl package was decompressed configure Execute configure in the directory in which the perl package was decompressed make Install as the root account in the directory
86. s in each class please refer to Microsofts ADO NET standards Table 4 2 Classes for Connection Query Execution and Result Retrieval Class Description AltibaseConnection Establish a connection to a database and start a transaction AltibaseCommand Execute a query at a database and display parameters AltibaseDataReader Retrieve and output the result of command execution from a database Application Program Interface Users Manual 56 Using NET Data Provider Class Description AltibaseDataAdapter Fill DataSet with data and update data stored in a database Altibase NET Data Provider provides the followng classes for exception handling stored procedure and transaction processing Table 4 3 Classes for Exception Handling and Transaction Processing Class Description AltibaseException Framework Display a database error or a client error received from Net AltibaseParameter Define 1 0 parameters for a command or stored procedure AltibaseTransaction Allow execution of a transaction command in a database AltibaseType class has been defined to declare the data type of table columns or AltibaseParameter The Table 4 4 shows the relationship the data types provided by Altibase and NET Framework Table 4 4 The Relationships between Data Types AltibaseType ALTIBASE NET Framework Bigin
87. s zs Win32 a CHE AN Ui Visual Basic Visual C Visual J RE ESME SA BEET HES EEE EF j DOEN ConscoleApplicationT OOS S AL Wes RODI OSHA ConsoleapplicationT r amp 28588VLletEgl 71 Open a new project Figure 4 1 51 NET Data Provider Using NET Data Provider Figure 4 2 Add Reference to Project ConsoleApplicationi Microsoft Visual Studio BE BAE HIV ZEME P VEB CHIAD HOEA ETD BW JIRLIEK SSH Gr SAS X Sal O C AE b Debug v Any CPU v command ASE 20889389 RG MES Program cs v X ConsoleApplicationi Program g amp Main sting args EFA ConsoleApplicationi 1 x 8E Hi using System B N cone ee dti using System Collections Generic D E fopeales using System Text BE namespace ConsoleApplication1 e TETA a Progran H static void Main string args lt gt Ras BEN as aa EI CSA gei BIG 8 148 8 sx E X a x Click the Add Reference to Project menu to register NET Data Provider Figure 4 2 Application Program Interface Users Manual 52 Using NET Data Provider Figure 4 3 Register Altibase NET Data Provider with Project ConsoleApplicationi Microsoft Visual Studio B x DSE BAE HAM ZEME P HEB CHIAD HOEA ETD EW ARLIEMC SEB i Ba EE Debug Any CPU v command aas zEORBARARR ub E A
88. sconnect statement into tx_close in ODBCCLI 101 XA Interface Using XA 4 You should change commit and rollback statements For example you should change EXEC SQL COMMIT into tx_commit and EXEC SQL ROLLBACK into tx_rollback in precompiler You should change SQLEndTran into tx_commiit or tx_rollback in OBDCCLI They start to execute transaction by calling tx begin 5 Application should reset fetched transaction after its end You should block cursor and clear the resource with CLOSE RELEASE statement after fetching data by using cursor before ending transaction ALTIBASE Statement TPM Functions CONNECT tx open Starting to execute transaction implicitly tx begin SOL Executing SOL in service COMMIT tx commit ROLLBACK tx rollback DISCONNECT tx close SET TRANSACTION READ ONLY Not allowed Application Program Interface Users Manual 102 XA Restriction XA Restriction Several restrictions are as follows when vou use XA SQL Use Restriction Transaction Branch Association Migration Asynchronixation Call Dynamic Registeration SQL Use Restriction Rollback and Commit XA application should not control global transaction with certain statement of ALTIBASE because TM manages global transaction You should use tx commit or tx rollback to shut down global transaction You can t use EXEC SQL ROLLBACK statement or EXEC SQL COMMIT statement in precompiler ODBCCLI should not m
89. se in coordinating the distributed transac tion An XAConnection instance is an instance of Altibase jdbc driver ABPooledConnection class in ALTIBASE JDBC driver The ABPooledConnection class getXAResource method returns an ABXAResource instance The get Connection method returns an ABConnection instance Application Program Interface Users Manual 106 JDBC Distributed Transaction Figure 6 5 ABPooledConnection Class lt nterface gt PooledConnection lt nterface gt XAConnection A ABPooled Connection ABConnection instance returned by getConnection method acts as a temporary handle to the phys ical connection and runs like common connection before participating in global transaction If ABConnection instance participates in global transaction auto commit is specified as false After global transaction terminates auto commit is restored to its original state prior to occurrence of global transaction Each time an XAConnection instance getConnection method is called it returns a new connection instance It had been returned by the same XAConnection instance and closes any previous connec tion instance tha still exists It is advisable to explicitly close any previous connection instance before opening a new one Calling the close method of an XAConnection instance closes the physical con nection to the database The TM uses ABXAResource instances to coordinate all the transac
90. shRow X boolean relative int rows O boolean rowDeleted X boolean rowInserted X boolean rowUpdated X void setFetchDirection int direction A void setFetchSize int rows O void updateArray int columnindex Array x X void updateArray String columnName Array x X void updateAsciiStream int columnindex InputStream x int X length void updateAsciiStream String columnName InputStream X x int length void updateBigDecimal int columnindex BigDecimal x X void updateBigDecimal String columnName BigDecimal x X void updateBinaryStream int columnindex InputStream x X int length void updateBinaryStream String columnName Input X Stream x int length void updateBlob int columnindex Blob x X void updateBlob String columnName Blob x X void updateBoolean int columnindex Boolean x X void updateBoolean String columnName Boolean x X void updateByte int columnindex byte x X void updateByte String columnName byte x X void updateBytes int columnindex bytel x X void updateBytes String columnName bytel x X Application Program Interface Users Manual 22 JDBC 2 1 Core API and JDBC 2 0 Optional Package API Return Function Name Support void updateCharacterStream int columnindex Reader x int X length void updateCharacterStream String columnName Reader X reader int length void updateClob int columnindex Cl
91. sourceParams name jdbc altidb gt lt parameter gt lt name gt factory lt name gt lt value gt org apache commons dbcp BasicDataSourceFactory lt value gt lt parameter gt lt Maximum connection count gt lt parameter gt lt name gt maxActive lt name gt lt value gt 5 lt value gt lt parameter gt lt Maximum connection count which is available to occur without executing it in pool gt lt parameter gt lt name gt maxIdle lt name gt lt value gt 3 lt value gt lt parameter gt lt Maximum waiting time until connection is completed unit millisecond lt parameter gt lt name gt maxWait lt name gt lt value gt 10000 lt value gt lt parameter gt lt parameter gt lt name gt removeAbandoned lt name gt lt value gt true lt value gt lt parameter gt lt parameter gt lt name gt removeAbandonedTimeout lt name gt lt value gt 60 lt value gt lt parameter gt lt parameter gt lt name gt username lt name gt lt value gt SYS lt value gt lt parameter gt lt parameter gt lt name gt password lt name gt Application Program Interface Users Manual 8 Connection Pool Configuration lt value gt MANAGER lt value gt lt parameter gt lt parameter gt lt name gt driverClassName lt name gt lt value gt Altibase jdbc driver AltibaseDriver lt value gt lt parameter gt lt parameter gt lt name gt url lt name gt lt value gt jdbc Altibase 1
92. stop executing transaction in TM TM controls transaction through TX interface as follows tvpicallv Table 6 3 TX Interface TX Interface Description tx open This denotes to log on RM tx_close This denotes to log out RM tx_begin This denotes to start executing new transaction tx commit This commits transaction tx rollback This rollbacks transaction The process is as follows to call TX and XA interfaces Figure 6 2 The Process of Calling TX and XA Interfaces XA Interface AP TM tx_open xa open tx begin 4 xa start tx_commit xa_end xa_prepare xa_commit ALTIBASE tx_close y ty Xa close xa recover TIT xa commit xa rollback xa forget Native Calls T TPM application has client server structure requesting for service which its client provides in its server Service is work unit logically If you use ALTIBASE as RM unit denotes SQL statement set The following example assumes that application server already logs on TPM system Application Program Interface Users Manual 100 Using XA How to start executing transaction in application server The following example shows application server starts to execute transaction Client tpm service SERVICET Server SERVICE1 lt get service specific data gt tx begin EXEC SQL UPDATE tpm service SERVICE2
93. sult X SetConcurrency int resultSetHoldability PreparedStatement prepareStatement String sql X PreparedStatement prepareStatement String sql int autoGeneratedKeys PreparedStatement prepareStatement String sql inti columnIndexes PreparedStatement prepareStatement String sql int resultSetType int O resultSetConcurrency PreparedStatement prepareStatement String sql int resultSetType int X resultSetConcurrency int resultSetHoldability PreparedStatement prepareStatement String sql String columnNames X Application Program Interface Users Manual 12 JDBC 2 1 Core API and JDBC 2 0 Optional Package API Return Function Name Support Void releaseSavepoint Savepoint savepoint O Void rollback O Void rollback Savepoint savepoint O Void setAutoCommit boolean autoCommit O Void setCatalog String catalog Void setHoldability int holdability X Void setReadOnly boolean readOnly X Savepoint setSavepoint O Savepoint setSavepoint String name O Void setTransactionlsolation int level O Void setTvpeMap Map map X Return Type Function Name Support Boolean allProceduresAreCallable O Boolean d O Boolean dataDefinitionCausesTransactionCommit O Boolean dataDefinitionlgnoredlnTransactions O Boolean deletesAreDetected int type O Boolean doesMaxRowsSizelncludeBlobs O ResultSet getAttributes String catalog String
94. t BIGINT Int64 Bit BIT Bytel Blob BLOB Byte Byte BYTE Bvtell Char CHAR String Clob CLOB String DateTime DATE DateTime Decimal DECIMAL Decimal Double DOUBLE Double Float FLOAT Decimal Geometrv GEOMETRV Bvtell Integer INT Int32 NChar NCHAR String Nibble NIBBLE Byte 57 NET Data Provider Using NET Data Provider AltibaseTvpe ALTIBASE NET Framework Number NUMBER Decimal Numeric NUMERIC Decimal NVarChar NVARCHAR String Real REAL Float Smallint SMALLINT Int16 VarBit VARBIT Bytel VarChar VARCHAR String You should add N in front of character string to use constant character string with national charac ter type in SQL statements Application Program Interface Users Manual 58 Interface Setting for NET Data Provider Interface Setting for NET Data Provider Interface Setting Independent programming is available for ADO NET Provider subsequent releases starting with version 2 0 DbProviderFactories class enables user to obtain DbProviderFactory class of provider which he requires Therefore he can create and use DbConnection or DbCommand objects with DbProvider Factory class However factory information of NET Data Provider should be registered in the setting file of NET Framework to use DbProviderFactories There are two ways to register factory information To register NET Framework in the setting file To use the environment setting file
95. tObject String parameterName Map map X Ref getRef int i X Ref getRef String parameterName X short getShort int parameterlndex O Application Program Interface Users Manual 28 JDBC 2 1 Core API and JDBC 2 0 Optional Package API Return Tvpe Function Name Support short getShort String parameterName X String getString int parameterlndex O String getString String parameterName X Time getTime int parameterlndex O Time getTime int parameterlndex Calendar cal A Time getTime String parameterName X Time getTime String parameterName Calendar cal X Timestamp getTimestamplint parameterlndex O Timestamp getTimestamplint parameterlndex Calendar cal A Timestamp getTimestamp String parameterName X Timestamp getTimestamp String parameterName Calendar cal X URL getURL int parameterlndex X URL getURL String parameterName X void registerOutParameter int parameterlndex int salType O void registerOutParameter int parameterlndex int sqlType O int scale void registerOutParameter int paramindex int sqlType O String typeName void registerOutParameter String parameterName int sql X Type void registerOutParameter String parameterName int sal X Type int scale void registerOutParameter String parameterName int sql X Type String typeName void setAsciiStream String parameterName InputStream x X int length void setBigDecim
96. tar gz tar xvf Makefile is created with install mk make f install mk Make The shared library for Altibase perl DBD altibase sl is created For platforms other than HP altibas so is created in blib arch auto DBD altibase Execute make install as the super user Altibase perl DBD is installed in perl Ex opt perl 5 8 8 bin lib site per1 5 8 8 IA64 ARCHREV 0 auto DBD altibase SetLD PRELOAD This task should be performed for HP or certain other platforms Otherwise an error message will be displayed Execute perl test pl After starting the Altibase server change the test pl code as in the below and execute perl test pl Application Program Interface Users Manual 46 Installing Altibase DBD my dbh DBI sconnect dbi altibase DSN 127 0 0 1 UID SYS PWD MANAGER CONN TYPE 1 NLS USE US7ASCII PORT NO 20999 m RaiseError gt 1 47 PERL DBD DBI Installing Altibase DBD Application Program Interface Users Manual 48 4 NET Data Provider This chapter describes how to Microsoft s ADO NET interface with Altibase DBMS 49 NET Data Provider NET Data Provider Overview NET Data Provider Overview Overview Altibase5 NET Data Provider is implementation of Microsoft s ADO NET interface for Altibase DBMS That is Altibase5 NET Data Provider is required to use Altibase5 for NET Framework based applica tions ADO NET interface uses NET Framework to access data sources such
97. the following information if window is displayed for basic setup Application Program Interface Users Manual 110 DBMS Other Available Data Source JDBC Distributed Transaction Data Source Class Name Altibase jdbc driver ABXADataSource Data Source Tvpe XADataSource 3 Vou should insert values for Database Name Port Number Server Name User and Password Figure 6 9 Data Source Setting in JEUS 03 env put Context URL PKG PREFIXES 127 0 0 1 env put Context env put Context env put Context ctx PROVIDER URL SECURITY PRINCIPAL jeus SECURITY CREDENTIALS jeus new InitialContext env System out println Context Created Ctx step 2 get User Transaction Object 111 JDBC QIOIE AA AHI JIE HA 7E aa AS E Export Name altiTXDS OIOIE1 2 459 anor DIE Vendor others Iv oec Ecol HO OIS Data Source Class Name Altibase jdbc driver ABXADataSource JDBC PHOS HOE AA 8449Y OS MIIA SS EIE 2145 SIEHOJOF SIC Data Source Type XADataSource Ie OIDIE1 2 59 Ee Database Name mydb GIOIEIHIOI 9 OIS Orade9 BS database SID Port Number 25226 Database listener2 ZE BE Server Name 192 168 1 31 Database J MATE SAE 015 EE IP User SYS DB AS Al ID EWAN Hol SS PUNE EEE HES PALL SIOIOE EIT Password plain v 9999 DB AHB AHS password JEUS Application Example step 1 JNDI Lookup and get UserTransaction Object Context ctx null Hashtable env new Hashtable Paramet
98. tion branches An Alti bse jdbc driver ABXAResource instance is an instance of a class that implements the javax transac tion xa XAResource interface Figure 6 6 ABXAResource Class lt nterface gt Javax transaction xa XAResource A ABXAResource The ALTIBASE JDBC driver creates and returns an ABXAResource instance whenever the ABPooled Connection class getXAResource method is called and associates an ALTIBASE JDBC driver ABXARe 107 XA Interface JDBC Distributed Transaction source instance with an connection instance Transaction branch is executed through that connection The ABXAResource class has serveral methods to coordinate a transaction branch with the distrib uted transaction A TM receiving ABXAResource instances from a middle tier component such as application server tvpicallv invokes the following functionalities void start Xid xid int flags void end Xid xid int flags int prepare Xid xid void commit Xid xid boolean onePhase void rollback Xid xid public void forget Xid xid public Xid recover int flag Refer to javax transaction xa XAResource of java API Spec for details Xid interface TM creates transaction ID instances and uses them in coordinating the branches of distributed trans action Each transaction branch is assigned a unique transaction ID which includes the following informaiton Format identifier Global transaction identifier Branch
99. tion of RM and entry point struct xa switch t char name RMNAMESZ name of resource manager long flags resource manager specific options long version int xa open entry char int long 4 xa open fn pointer int xa close entry char int long 4 xa close fn pointer int xa start entry XID int long xa start fn pointer int xa end entry XID int long _ xa end fn pointer int xa rollback entry XID int long xa rollback fn pointer int xa prepare entry XID int long 4 xa prepare fn pointer int xa commit entry XID int long xa commit fn pointer int xa recover entry XID long int long _ xa recover fn pointer int xa forget entry XID int long 4 xa forget fn pointer int xa complete entry int int int long xa complete fn pointer XA Library Extra library isn t reguired for connecting to application with ALTIBASE XA because it is included in odbccil library You should connect application with XA to libodbccli a for using functionality related to XA Application Program Interface Users Manual 86 XA Interface XA Interface This is assumed mutual interface between RM and TM TM consists of XA routine controling RM to execute global trasaction and AX routine which RM requests to TM dynamically However you should call x
100. tream x X int length void setURL int parameterindex URL x X Return Tvpe Function Name Support Arrav getArray int i X Array getArray String parameterName BigDecimal getBigDecimal int parameterindex O 27 JDBC JDBC 2 1 Core API and JDBC 2 0 Optional Package API Return Tvpe Function Name Support BigDecimal getBigDecimal int parameterlndex int scale O BigDecimal getBigDecimal String parameterName X Blob getBlob int i O Blob getBlob String parameterName X boolean getBoolean int parameterlndex O boolean getBoolean String parameterName X byte getByte int parameterindex O byte getByte String parameterName X bytel getBytes int parameterlndex O bytel getBytes String parameterName X Clob getClob int i X Clob getClob String parameterName X Date getDate int parameterlndex O Date getDate int parameterlndex Calendar cal A Date getDate String parameterName O Date getDate String parameterName Calendar cal A double getDouble int parameterlndex O double getDouble String parameterName X float getFloat int parameterlndex O float getFloat String parameterName X int getint int parameterlndex O int getint String parameterName X long getLong int parameterlndex O long getLong String parameterName X Object getObject int parameterlndex O Object getObject int i Map map A Object getObject String parameterName X Object ge
101. utoGeneratedKeys X int executeUpdate String sql inti columnindexes X int executeUpdate String sql String columnNames X Connection getConnection O int getFetchDirection O int getFetchSize O ResultSet getGeneratedKeys X int getMaxFieldSize O int getMaxRows O boolean getMoreResults O boolean getMoreResults int current O int getQueryTimeout O ResultSet getResultSet O int getResultSetConcurrency O int getResultSetHoldability O int getResultSetType O int getUpdateCount O 25 JDBC JDBC 2 1 Core API and JDBC 2 0 Optional Package API Return Tvpe Function Name Support SQLWarning getWarnings O void setCursorName String name X void setEscapeProcessing Boolean enable X void setFetchDirection int direction A void setFetchSize int rows O void setMaxFieldSize int max O void setMaxRows int max O void setQueryTimeout int seconds O Return Type Function Name Support void addBatch O void clearParameters O boolean execute O ResultSet executeQuery O int executeUpdatel O ResultSetMetaData getMetaData O ParameterMetaData getParameterMetaData X void setArray int i Array x X void setAsciiStream int parameterlndex InputStream x int O length void setBigDecimal int parameterindex BigDecimal x O void setBinaryStream int parameterlndex InputStream x int O length void setBlob int i Blob x O void s

Download Pdf Manuals

image

Related Search

Related Contents

Pyle Amplifiers User Manual  Enduit de rebouchage - Seigneurie Gauthier  OSM-023 Sucker Rod Elevator - Al  Mod. 50190 Monoblocco Pellet 800P M14    Este manual é para uso exclusivo do Sr. LUCIANO SEPÚLVEDA  heben sie diese bedienungsanleitung auf  取扱説明書  HERMA CD labels Maxi A4 Ø 116 mm white paper matt opaque 20 pcs.  Samsung SGH-B520 Hướng dẫn sử dụng  

Copyright © All rights reserved.
Failed to retrieve file