javacli
Class Connection

java.lang.Object
  extended byjavacli.Connection

public class Connection
extends java.lang.Object

Gigabase interface responsible for managing connection with GigaBASE server. Also it implements insert commit, rollback operations


Field Summary
static int cli_already_updated
           
static int cli_bad_address
           
static int cli_bad_statement
           
static int cli_closed_connection
           
static int cli_closed_statement
           
static int cli_column_not_found
           
static int cli_connection_refused
           
static int cli_database_not_found
           
static int cli_empty_parameter
           
static int cli_incompatible_type
           
static int cli_login_failed
           
static int cli_network_error
           
static int cli_not_all_columns_specified
           
static int cli_not_fetched
           
static int cli_not_found
           
static int cli_not_implemented
           
static int cli_not_update_mode
           
static int cli_ok
           
static int cli_parameter_not_found
           
static int cli_runtime_error
           
static int cli_table_already_exists
           
static int cli_table_not_found
           
static int cli_unbound_parameter
           
static int cli_unsupported_type
           
 
Constructor Summary
Connection()
           
 
Method Summary
 void addIndex(java.lang.String tableName, java.lang.String fieldName)
          Add case sensitive index
 void addIndex(java.lang.String tableName, java.lang.String fieldName, boolean caseInsensitive)
          Add index
 void addPackage(java.lang.String pkName)
          Add package name to the list of registered package.
 void close()
          Close connection with server
 void commit()
          Commit current transaction
 Statement createStatement(java.lang.String sql)
          Create select statement.
 boolean createTable(java.lang.Class cls)
          Create table matching specified class.
 boolean createTable(java.lang.Class cls, java.util.HashMap referenceMap)
          Create table matching specified class.
 void dropIndex(java.lang.String tableName, java.lang.String fieldName)
          Drop index
 void dropTable(java.lang.Class cls)
          Drop table corresponding to the specified class.
 void dropTable(java.lang.String tableName)
          Drop specified table
 Reference insert(java.lang.Object obj)
          Insert object in the database.
 void open(java.lang.String hostAddress, int hostPort)
          Open onnection with server
 void open(java.lang.String hostAddress, int hostPort, java.lang.String userName, java.lang.String userPassword)
          Open connection with server
 void precommit()
          Release all locks set by the current transaction
 void rollback()
          Rollback curent transaction.Al changes made by current transaction are lost.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cli_ok

public static final int cli_ok
See Also:
Constant Field Values

cli_bad_address

public static final int cli_bad_address
See Also:
Constant Field Values

cli_connection_refused

public static final int cli_connection_refused
See Also:
Constant Field Values

cli_database_not_found

public static final int cli_database_not_found
See Also:
Constant Field Values

cli_bad_statement

public static final int cli_bad_statement
See Also:
Constant Field Values

cli_parameter_not_found

public static final int cli_parameter_not_found
See Also:
Constant Field Values

cli_unbound_parameter

public static final int cli_unbound_parameter
See Also:
Constant Field Values

cli_column_not_found

public static final int cli_column_not_found
See Also:
Constant Field Values

cli_incompatible_type

public static final int cli_incompatible_type
See Also:
Constant Field Values

cli_network_error

public static final int cli_network_error
See Also:
Constant Field Values

cli_runtime_error

public static final int cli_runtime_error
See Also:
Constant Field Values

cli_closed_statement

public static final int cli_closed_statement
See Also:
Constant Field Values

cli_unsupported_type

public static final int cli_unsupported_type
See Also:
Constant Field Values

cli_not_found

public static final int cli_not_found
See Also:
Constant Field Values

cli_not_update_mode

public static final int cli_not_update_mode
See Also:
Constant Field Values

cli_table_not_found

public static final int cli_table_not_found
See Also:
Constant Field Values

cli_not_all_columns_specified

public static final int cli_not_all_columns_specified
See Also:
Constant Field Values

cli_not_fetched

public static final int cli_not_fetched
See Also:
Constant Field Values

cli_already_updated

public static final int cli_already_updated
See Also:
Constant Field Values

cli_table_already_exists

public static final int cli_table_already_exists
See Also:
Constant Field Values

cli_not_implemented

public static final int cli_not_implemented
See Also:
Constant Field Values

cli_login_failed

public static final int cli_login_failed
See Also:
Constant Field Values

cli_empty_parameter

public static final int cli_empty_parameter
See Also:
Constant Field Values

cli_closed_connection

public static final int cli_closed_connection
See Also:
Constant Field Values
Constructor Detail

Connection

public Connection()
Method Detail

open

public void open(java.lang.String hostAddress,
                 int hostPort)
Open onnection with server

Parameters:
hostAddress - string with server host name
hostPort - integer number with server port

open

public void open(java.lang.String hostAddress,
                 int hostPort,
                 java.lang.String userName,
                 java.lang.String userPassword)
Open connection with server

Parameters:
hostAddress - string with server host name
hostPort - integer number with server port
userName - user name
userPassword - password

addPackage

public void addPackage(java.lang.String pkName)
Add package name to the list of registered package. The name of the each registered package will be appended to the table name when Java class for the database table is located.

Parameters:
pkName - - name of the package

close

public void close()
Close connection with server


createStatement

public Statement createStatement(java.lang.String sql)
Create select statement.

Parameters:
sql - - SubSQL select statement with parameters. Paameters should be started with % character. Each used paramter should be set before execution of the statement.

commit

public void commit()
Commit current transaction


precommit

public void precommit()
Release all locks set by the current transaction


rollback

public void rollback()
Rollback curent transaction.Al changes made by current transaction are lost.


insert

public Reference insert(java.lang.Object obj)
Insert object in the database. There is should be table in the database with name equal to the full class name of the inserted object (comparison is case sensitive). GigaBASE will store to the database all non-static and non-transient fields from the class. All Java primitive types, java.lang.String, arrays of primitive types or strings, java.util.Date are supported by GigaBASE. If int field is marked as volatile, it is assumed to be autoincremented field - unique value to this field is assigned automatically by GigaBASE.

Parameters:
obj - - object to be inserted inthe database
Returns:
reference to th inserted object

createTable

public boolean createTable(java.lang.Class cls)
Create table matching specified class. Name of the table is equal to class name without any package prefixes. This table will include columns corresponsinf to all non-static and non-transient fields of specified class and base classes of this class.

Parameters:
cls - Java class for which table should be created.
Returns:
true if table sucessfully created, false if table already exists
Throws:
throws - CliError exception in case of all other errors (except table already exists)

createTable

public boolean createTable(java.lang.Class cls,
                           java.util.HashMap referenceMap)
Create table matching specified class. Name of the table is equal to class name without any package prefixes. This table will include columns corresponsinf to all non-static and non-transient fields of specified class and base classes of this class.

Parameters:
cls - Java class for which table should be created.
referenceMap - map to provide names of referenced tables for reference fields. Key of this map is field name.
Returns:
true if table sucessfully created, false if table already exists
Throws:
throws - CliError exception in case of all other errors (except table already exists)

dropTable

public void dropTable(java.lang.Class cls)
Drop table corresponding to the specified class.

Parameters:
cls - Java class for which should be created. Name of the table is the same as name of the class without any package prefixes.

dropTable

public void dropTable(java.lang.String tableName)
Drop specified table

Parameters:
tableName - name of the table

addIndex

public void addIndex(java.lang.String tableName,
                     java.lang.String fieldName)
Add case sensitive index

Parameters:
tableName - name of the table
fieldName - name of the field

addIndex

public void addIndex(java.lang.String tableName,
                     java.lang.String fieldName,
                     boolean caseInsensitive)
Add index

Parameters:
tableName - name of the table
fieldName - name of the field
caseInsensitive - attribute specifying whether index is case insensitive or not

dropIndex

public void dropIndex(java.lang.String tableName,
                      java.lang.String fieldName)
Drop index

Parameters:
tableName - name of the table
fieldName - name of the field