Java Doc for Datasource.java in  » Web-Framework » rife-1.6.1 » com » uwyn » rife » database » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Framework » rife 1.6.1 » com.uwyn.rife.database 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   com.uwyn.rife.database.Datasource

Datasource
public class Datasource implements Cloneable(Code)
Contains all the information required to connect to a database and centralizes the creation of connections to a database. These connections can optionally be pooled.

The initial connection will only be made and the pool will only be initialized when a connection is obtained for the first time. The instantiation only stores the connection parameters.

A Datasource also defines the type of database that is used for all database-independent logic such as sql to java and java to sql type mappings, query builders, database-based authentication, database-based scheduling, ... The key that identifies a supported type is the class name of the jdbc driver.

A Datasource instance can be created through it's constructor, but it's recommended to work with a Datasources collection that is created and populated through XML. This can easily be achieved by using a ParticipantDatasources which participates in the application-wide repository.

Once a connection has been obtained from a pooled datasource, modifying its connection parameters is not possible anymore, a new instance has to be created to set the parameters to different values.
author:
   Geert Bevin (gbevin[remove] at uwyn dot com)
version:
   $Revision: 3636 $
See Also:   com.uwyn.rife.database.Datasources
See Also:   com.uwyn.rife.database.Xml2Datasources
See Also:   com.uwyn.rife.rep.Rep
See Also:   com.uwyn.rife.rep.participants.ParticipantDatasources
since:
   1.0



Field Summary
static  HashMap<String, String>sDriverAliases
    
static  HashMap<String, String>sDriverNames
    

Constructor Summary
public  Datasource()
     Instantiates a new Datasource object with no connection information.
public  Datasource(String driver, String url, String user, String password, int poolsize)
     Instantiates a new Datasource object with all the connection parameters that are required.
public  Datasource(DataSource dataSource, int poolsize)
     Instantiates a new Datasource object from a standard javax.sql.DataSource.

The driver will be detected from the connection that is provided by this DataSource.

public  Datasource(DataSource dataSource, String driver, String user, String password, int poolsize)
     Instantiates a new Datasource object from a standard javax.sql.DataSource.

Method Summary
public  voidcleanup()
     Cleans up all connections that have been reserved by this datasource.
public  Datasourceclone()
     Simply clones the instance with the default clone method.
 DbConnectioncreateConnection()
     Creates a new connection by using all the parameters that have been defined in the Datasource.
public  booleanequals(Object object)
     Indicates whether some other object is "equal to" this one.
public  StringgetAliasedDriver()
     Retrieves the fully qualified class name of the jdbc driver that's used by this Datasource.
public  CapabilitiesCompensatorgetCapabilitiesCompensator()
    
public  DbConnectiongetConnection()
     Retrieves a free database connection.
public  DataSourcegetDataSource()
     Retrieves the standard datasource that is used by this RIFE datasource to obtain a database connection.
public  StringgetDriver()
     Retrieves the fully qualified class name of the jdbc driver that's used by this Datasource.
public  StringgetPassword()
     Retrieves the password that's used by this Datasource.
public  ConnectionPoolgetPool()
     Retrieves the instance of the connection pool that is provided by this dtaasource.
public  intgetPoolsize()
     Retrieves the size of the pool that's used by this Datasource.
public  SqlConversiongetSqlConversion()
     Retrieves the sql to java and java to sql type mapping logic that corresponds to the provide driver class name.
public  StringgetUrl()
     Retrieves the connection url that's used by this Datasource.
public  StringgetUser()
     Retrieves the user that's used by this Datasource.
public  inthashCode()
     Returns a hash code value for the Datasource.
public  booleanisPooled()
    
public  voidsetDataSource(DataSource dataSource)
     Sets the standard datasource that will be used to connect to the database.
public  voidsetDriver(String driver)
     Sets the jdbc driver that will be used to connect to the database.
public  voidsetPassword(String password)
     Sets the password that will be used to connect to the database.
public  voidsetPoolsize(int poolsize)
     Sets the size of the connection pool that will be used to connect to the database.
public  voidsetUrl(String url)
     Sets the connection url that will be used to connect to the database.
public  voidsetUser(String user)
     Sets the user that will be used to connect to the database.

Field Detail
sDriverAliases
static HashMap<String, String> sDriverAliases(Code)



sDriverNames
static HashMap<String, String> sDriverNames(Code)




Constructor Detail
Datasource
public Datasource()(Code)
Instantiates a new Datasource object with no connection information. The setters need to be used afterwards to provide each required parameter before the Datasource can be used.
See Also:   Datasource.setDriver(String)
See Also:   Datasource.setUrl(String)
See Also:   Datasource.setUser(String)
See Also:   Datasource.setPassword(String)
See Also:   Datasource.setPoolsize(int)
See Also:   Datasource.setDataSource(DataSource)
since:
   1.0



Datasource
public Datasource(String driver, String url, String user, String password, int poolsize)(Code)
Instantiates a new Datasource object with all the connection parameters that are required.
Parameters:
  driver - the fully-qualified classname of the jdbc driver that willbe used to connect to the database
Parameters:
  url - the connection url which identifies the database to which theconnection will be made, this is entirely driver-dependent
Parameters:
  user - the user that will be used to connect to the database
Parameters:
  password - the password that will be used to connect to the database
Parameters:
  poolsize - the size of the connection pool, 0 meansthat the connections will not be pooled
since:
   1.0



Datasource
public Datasource(DataSource dataSource, int poolsize)(Code)
Instantiates a new Datasource object from a standard javax.sql.DataSource.

The driver will be detected from the connection that is provided by this DataSource. If the driver couldn't be detected, an exception will be thrown upon connect.
Parameters:
  dataSource - the standard datasource that will be used to obtain theconnection
Parameters:
  poolsize - the size of the connection pool, 0 meansthat the connections will not be pooled
since:
   1.3




Datasource
public Datasource(DataSource dataSource, String driver, String user, String password, int poolsize)(Code)
Instantiates a new Datasource object from a standard javax.sql.DataSource.
Parameters:
  dataSource - the standard datasource that will be used to obtain theconnection
Parameters:
  driver - the fully-qualified classname of the jdbc driver that willbe used to provide an identifier for the database abstraction functionalities,null will let RIFE try to figure it out by itself
Parameters:
  user - the user that will be used to connect to the database
Parameters:
  password - the password that will be used to connect to the database
Parameters:
  poolsize - the size of the connection pool, 0 meansthat the connections will not be pooled
since:
   1.3




Method Detail
cleanup
public void cleanup() throws DatabaseException(Code)
Cleans up all connections that have been reserved by this datasource.
throws:
  DatabaseException - when an error occured during the cleanup
since:
   1.0



clone
public Datasource clone()(Code)
Simply clones the instance with the default clone method. This creates a shallow copy of all fields and the clone will in fact just be another reference to the same underlying data. The independence of each cloned instance is consciously not respected since they rely on resources that can't be cloned.
since:
   1.0



createConnection
DbConnection createConnection() throws DatabaseException(Code)
Creates a new connection by using all the parameters that have been defined in the Datasource. the newly created DbConnection instance
throws:
  DatabaseException - when an error occured during the creation ofthe connection
since:
   1.0



equals
public boolean equals(Object object)(Code)
Indicates whether some other object is "equal to" this one. Only the real connection parameters will be taken into account. The size of the pool is not used for the comparison.
Parameters:
  object - the reference object with which to compare. true if this object is the same as the objectargument; or

false otherwise
See Also:   Datasource.hashCode()
since:
   1.0




getAliasedDriver
public String getAliasedDriver()(Code)
Retrieves the fully qualified class name of the jdbc driver that's used by this Datasource. Instead of straight retrieval of the internal value, it looks for jdbc driver aliases and changes the driver classname if it's not supported by RIFE, but its alias is. a String with the name of the jdbc driver; or

null if the driver hasn't been set
See Also:   Datasource.getDriver()
See Also:   Datasource.setDriver(String)
since:
   1.0




getCapabilitiesCompensator
public CapabilitiesCompensator getCapabilitiesCompensator() throws UnsupportedJdbcDriverException(Code)
Retrieves a CapabilitiesCompensator instance that is able to compensate for certain missing database features the requested CapabilitiesCompensator instance
throws:
  UnsupportedJdbcDriverException - when the provided jdbc isn'tsupported
since:
   1.0



getConnection
public DbConnection getConnection() throws DatabaseException(Code)
Retrieves a free database connection. If no connection pool is used, a new DbConnection will always be created, otherwise the first available connection in the pool will be returned. a free DbConnection instance which can be used tocreate an execute statements
throws:
  DatabaseException - when errors occured during the creation of anew connection or during the obtainance of a connection from the pool
since:
   1.0



getDataSource
public DataSource getDataSource()(Code)
Retrieves the standard datasource that is used by this RIFE datasource to obtain a database connection. a standard DataSource; or

null if the standard datasource hasn't been set
See Also:   Datasource.setDataSource(DataSource)
since:
   1.3




getDriver
public String getDriver()(Code)
Retrieves the fully qualified class name of the jdbc driver that's used by this Datasource. a String with the name of the jdbc driver; or

null if the driver hasn't been set
See Also:   Datasource.setDriver(String)
See Also:   Datasource.getAliasedDriver()
since:
   1.0




getPassword
public String getPassword()(Code)
Retrieves the password that's used by this Datasource. a String>/code> with the password; or

null if the password hasn't been set
See Also:   Datasource.setPassword(String)
since:
   1.0




getPool
public ConnectionPool getPool()(Code)
Retrieves the instance of the connection pool that is provided by this dtaasource. the requested instance of ConnectionPool



getPoolsize
public int getPoolsize()(Code)
Retrieves the size of the pool that's used by this Datasource. a positive int with the size of the pool; or

0 if no pool is being used
See Also:   Datasource.isPooled()
See Also:   Datasource.setPoolsize(int)
since:
   1.0




getSqlConversion
public SqlConversion getSqlConversion() throws UnsupportedJdbcDriverException(Code)
Retrieves the sql to java and java to sql type mapping logic that corresponds to the provide driver class name. a SqlConversion instance that is able to performthe required type conversions for the provided jdbc driver
throws:
  UnsupportedJdbcDriverException - when the provided jdbc isn'tsupported
since:
   1.0



getUrl
public String getUrl()(Code)
Retrieves the connection url that's used by this Datasource. a String with the connection url; or

null if the url hasn't been set
See Also:   Datasource.setUrl(String)
since:
   1.0




getUser
public String getUser()(Code)
Retrieves the user that's used by this Datasource. a String>/code> with the user; or

null if the user hasn't been set
See Also:   Datasource.setUser(String)
since:
   1.0




hashCode
public int hashCode()(Code)
Returns a hash code value for the Datasource. This method is supported for the benefit of hashtables such as those provided by java.util.Hashtable. an int with the hash code value for thisDatasource.
See Also:   Datasource.equals(Object)
since:
   1.0



isPooled
public boolean isPooled()(Code)
Indicates whether the Datasource uses a connection pool or not true if a pool is being used by thisDatasource; or

false otherwise
See Also:   Datasource.getPoolsize()
See Also:   Datasource.setPoolsize(int)
since:
   1.0




setDataSource
public void setDataSource(DataSource dataSource)(Code)
Sets the standard datasource that will be used to connect to the database.
Parameters:
  dataSource - a standard DataSource that will be usedby this RIFE datasource to obtain a database connection.
See Also:   Datasource.getDataSource()
since:
   1.0



setDriver
public void setDriver(String driver)(Code)
Sets the jdbc driver that will be used to connect to the database. This has to be a fully qualified class name and will be looked up through reflection. It's not possible to change the driver after a connection has been obtained from a pooled datasource.

If the class name can't be resolved, an exception is thrown during the creation of the first connection.
Parameters:
  driver - a String with the fully qualified class nameof the jdbc driver that will be used
See Also:   Datasource.getDriver()
since:
   1.0




setPassword
public void setPassword(String password)(Code)
Sets the password that will be used to connect to the database. It's not possible to change the password after a connection has been obtained from a pooled datasource.
Parameters:
  password - a String with the password that will be used
See Also:   Datasource.getPassword()
since:
   1.0



setPoolsize
public void setPoolsize(int poolsize)(Code)
Sets the size of the connection pool that will be used to connect to the database.
Parameters:
  poolsize - a positive int with the size of the pool,providing 0 will disable the use of a connection pool forthis Datasource.
See Also:   Datasource.getPoolsize()
See Also:   Datasource.isPooled()
since:
   1.0



setUrl
public void setUrl(String url)(Code)
Sets the connection url that will be used to connect to the database. It's not possible to change the url after a connection has been obtained from a pooled datasource.
Parameters:
  url - a String with the connection url that will beused
See Also:   Datasource.getUrl()
since:
   1.0



setUser
public void setUser(String user)(Code)
Sets the user that will be used to connect to the database. It's not possible to change the user after a connection has been obtained from a pooled datasource.
Parameters:
  user - a String with the user that will be used
See Also:   Datasource.getUser()
since:
   1.0



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.