SQLTuple version: 1.2.0.0

hep.aida.ref.sql
Class Accessor

java.lang.Object
  extended by hep.aida.ref.sql.Accessor

public class Accessor
extends Object

Accessor provides access to RDBMS. Following properties are required:

Static Accessor functions form an Accesor Factory. It tries to reuse already created Accessors if they share the same characteristics (options).

 $Log: Accessor.java,v $
 Revision 1.54  2007/09/26 07:58:51  hrivnac
 cache savable fromjas menu

 Revision 1.53  2007/05/23 16:38:43  hrivnac
 logical connections for Plotter; better UML

 Revision 1.52  2007/05/22 23:33:20  hrivnac
 Plotter uses real arguments parsing

 Revision 1.51  2006/12/15 00:16:13  hrivnac
 FORWARD_ONLY allows to plot big ntuples

 Revision 1.50  2006/12/12 15:21:42  hrivnac
 McKoi replaced with Derby; uppercase-only dbs handled better; moving to JAS 0.8.3

 Revision 1.49  2006/11/20 13:51:59  hrivnac
 Connection is closed except within JAS3

 Revision 1.48  2006/11/15 16:16:01  hrivnac
 Oracle work fine in CERN, cache enabled

 Revision 1.47  2004/12/07 01:04:56  hrivnac
 name pattern can be specified

 Revision 1.46  2004/12/01 16:07:15  hrivnac
 better support for ColMan JAS3 plugin

 Revision 1.45  2004/11/24 14:32:32  hrivnac
 better support for schemas

 Revision 1.44  2004/11/22 18:09:52  hrivnac
 Oracle treatment

 Revision 1.43  2004/10/29 22:27:25  hrivnac
 imports corrected

 Revision 1.42  2004/10/27 14:19:03  hrivnac
 small bug fixes

 Revision 1.41  2004/10/22 15:32:59  hrivnac
 cleaned

 Revision 1.40  2004/10/22 14:22:44  hrivnac
 properties loading refactored

 Revision 1.39  2004/10/20 23:02:29  hrivnac
 Types mapping simplified

 Revision 1.38  2004/10/12 13:25:40  hrivnac
 small improvements

 Revision 1.37  2004/10/08 15:22:33  hrivnac
 JAS3 plugin works

 Revision 1.36  2004/05/22 15:12:59  hrivnac
 class id reformated

 Revision 1.35  2004/04/16 15:32:57  hrivnac
 Type.properties to setup Type.class

 Revision 1.34  2004/04/14 13:54:41  hrivnac
 potential bugs fixed

 Revision 1.33  2004/04/14 13:39:46  hrivnac
 1.5 warnings fixed

 Revision 1.32  2004/04/13 15:45:54  hrivnac
 AIDA URL introduced

 Revision 1.31  2004/03/10 13:55:57  hrivnac
 *** empty log message ***

 Revision 1.30  2004/03/10 13:55:15  hrivnac
 *** empty log message ***

 Revision 1.29  2004/02/12 16:39:40  hrivnac
 niceing

 Revision 1.28  2004/02/10 14:50:58  hrivnac
 JavaDoc tags completed

 Revision 1.27  2004/02/04 13:30:39  hrivnac
 - improvement of Enums internal mapping
 - general cleaning

 Revision 1.26  2004/01/30 18:10:30  hrivnac
 - StmtSrc.properties specified a Property
 - customised FreeHEP AIDA services included in jar file

 Revision 1.25  2003/11/20 17:21:57  hrivnac
 Java 1.5 natively supported, Log4J reporting improved.

 Revision 1.24  2003/11/17 10:18:28  hrivnac
 Cleaning.

 Revision 1.23  2003/11/05 19:46:22  hrivnac
 - FreeHEP 1.2.1
 - JAIDA 3.2.1

 Revision 1.10  2003/10/10 13:21:36  hrivnac
 Works between different DB technologies.

 Revision 1.9  2003/10/10 10:12:21  hrivnac
 All three testing pgms work.

 Revision 1.5  2003/10/03 16:02:21  hrivnac
 Better handling of multiple technologies.

 Revision 1.3  2003/10/02 14:24:00  hrivnac
 Cleaning.

 Revision 1.2  2003/10/02 10:00:40  hrivnac
 Cleaning.

 

Version:
$Id: Accessor.java,v 1.54 2007/09/26 07:58:51 hrivnac Exp $
Author:
J.Hrivnac

Field Summary
private static Map<Map,Accessor> _accessors
           
private  Connection _connection
           
private  String _db
           
private  boolean _forwardOnly
           
private  String _passwd
           
private  String _protocol
           
private  String _schema
           
private  String _src
           
private  Type _types
           
private  String _user
           
private static boolean _withinJAS
           
private static Logger log
          Logging .
 
Constructor Summary
private Accessor(Map optionsMap)
          Creates using informations from Map.
private Accessor(String optionsString)
          Create using informations from properties String.
 
Method Summary
 void close()
          Close connection.
 void commit()
          Commit.
 Connection connection()
          Gives Connection, creates one if it doesn't exist yet.
 String creationCommand()
          Give the database creation command, if needed.
 String db()
          Give connected database name.
 String driver()
          Give used driver.
 boolean equals(Object other)
          Check, if both Accessors use the same driver, database, schema (if set), user and src
 boolean forwardOnly()
          Tell if ResultSet should be FOWARD_ONLY.
static Accessor getAccessor(Map optionsMap)
          Get Accesor corresponding to optionsMap if it already exists.
static Accessor getAccessor(String optionsString)
          Get Accesor corresponding to optionsString if it already exists.
static boolean isWinhinJAS()
          TBD
 String passwd()
          Give connected user' password.
 String protocol()
          Give used protocol.
 void rollback()
          Roll back.
 String schema()
          Give connected database schema.
 void setSrc(String src)
          Set connected StmtSrc.properties.
static void setWithinJAS()
          TBD
 String sqlName(Class aidaType)
          Give native SQL type name corresponding to Java Class.
 String src()
          Give connected StmtSrc.properties.
 boolean supportsOnlyForwardOnly()
          Tell if database supports only TYPE_FORWARD_ONLY cursor.
 boolean supportsOnlyUpperCase()
          Tell if database supports only uppercase names..
 boolean supportsReplication()
          Tell if database supports replication.
 String toString()
           
 String user()
          Give connected user.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_withinJAS

private static boolean _withinJAS

_accessors

private static Map<Map,Accessor> _accessors

_protocol

private String _protocol

_connection

private Connection _connection

_types

private Type _types

_db

private String _db

_schema

private String _schema

_src

private String _src

_user

private String _user

_passwd

private String _passwd

_forwardOnly

private boolean _forwardOnly

log

private static Logger log
Logging .

Constructor Detail

Accessor

private Accessor(Map optionsMap)
          throws SQLTupleException
Creates using informations from Map.

Parameters:
optionsMap - The map of options to define the Accessor.
Throws:
SQLTupleException - if the Accessor can't be created

Accessor

private Accessor(String optionsString)
          throws SQLTupleException
Create using informations from properties String.

Parameters:
optionsString - The string of name=option pairs to define the Accessor (separated by ;).
Throws:
SQLTupleException - if the Accessor can't be created.
Method Detail

getAccessor

public static Accessor getAccessor(Map optionsMap)
                            throws SQLTupleException
Get Accesor corresponding to optionsMap if it already exists. Creates new Accessor otherwise.

Parameters:
optionsMap - The map of options to define the Accessor.
Returns:
The Accessor associated to specified optionsMap.
Throws:
SQLTupleException

getAccessor

public static Accessor getAccessor(String optionsString)
                            throws SQLTupleException
Get Accesor corresponding to optionsString if it already exists. Creates new Accessor otherwise.

Parameters:
optionsString - The string of name=option pairs to define the Accessor (separated by ;).
Returns:
The Accessor associated to specified optionsString.
Throws:
SQLTupleException - if the Accessor can't be created.

connection

public Connection connection()
                      throws SQLTupleException
Gives Connection, creates one if it doesn't exist yet.

Returns:
The Connection defined by this Accessor.
Throws:
SQLTupleException - if the Connection can't be obtained.

sqlName

public String sqlName(Class aidaType)
Give native SQL type name corresponding to Java Class.

Parameters:
aidaType - The Java Class representing AIDA type.
Returns:
The corresponding native SQL type name.

commit

public void commit()
            throws SQLTupleException
Commit.

Throws:
SQLTupleException - if the Connection can't be commited.

rollback

public void rollback()
              throws SQLTupleException
Roll back.

Throws:
SQLTupleException - if the Connection can't be rolledback.

close

public void close()
           throws SQLTupleException
Close connection.

Throws:
SQLTupleException - if the Connection can't be closed.

equals

public boolean equals(Object other)
Check, if both Accessors use the same driver, database, schema (if set), user and src

Overrides:
equals in class Object

driver

public String driver()
Give used driver.

Returns:
The name of the associated SQL driver Class.

creationCommand

public String creationCommand()
Give the database creation command, if needed.

Returns:
The database creation command, if needed.

protocol

public String protocol()
Give used protocol.

Returns:
The name of the associated JDBC protocol.

supportsReplication

public boolean supportsReplication()
Tell if database supports replication.

Returns:
Whether database supports replication.

supportsOnlyForwardOnly

public boolean supportsOnlyForwardOnly()
Tell if database supports only TYPE_FORWARD_ONLY cursor.

Returns:
Whether database supports only YPE_FORWARD_ONLY cursor.

supportsOnlyUpperCase

public boolean supportsOnlyUpperCase()
Tell if database supports only uppercase names..

Returns:
Whether database supports only uppercase names.

db

public String db()
Give connected database name.

Returns:
The name of the associated database.

schema

public String schema()
Give connected database schema.

Returns:
The schema of the associated database.

setSrc

public void setSrc(String src)
Set connected StmtSrc.properties.

Parameters:
src - The StmtSrc to be used, null means the default StmtSrc.

src

public String src()
Give connected StmtSrc.properties.

Returns:
The used StmtSrc.

user

public String user()
Give connected user.

Returns:
The used username.

passwd

public String passwd()
Give connected user' password.

Returns:
The used password.

forwardOnly

public boolean forwardOnly()
Tell if ResultSet should be FOWARD_ONLY.

Returns:
Whether ResultSet should be FOWARD_ONLY.

setWithinJAS

public static void setWithinJAS()
TBD


isWinhinJAS

public static boolean isWinhinJAS()
TBD


toString

public String toString()
Overrides:
toString in class Object

Written by: J.Hrivnac

Documentation built November 9 2010 on Linux by hrivnac