Java Doc for Fastpath.java in  » Database-JDBC-Connection-Pool » postgresql » org » postgresql » fastpath » 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 » Database JDBC Connection Pool » postgresql » org.postgresql.fastpath 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.postgresql.fastpath.Fastpath

Fastpath
public class Fastpath (Code)
This class implements the Fastpath api.

This is a means of executing functions imbeded in the org.postgresql backend from within a java application.

It is based around the file src/interfaces/libpq/fe-exec.c




Constructor Summary
public  Fastpath(BaseConnection conn)
    

Method Summary
public  voidaddFunction(String name, int fnid)
     This adds a function to our lookup table.

User code should use the addFunctions method, which is based upon a query, rather than hard coding the oid.

public  voidaddFunctions(ResultSet rs)
     This takes a ResultSet containing two columns.
public static  FastpathArgcreateOIDArg(long oid)
     Creates a FastpathArg with an oid parameter.
public  Objectfastpath(int fnId, boolean resultType, FastpathArg[] args)
    
public  Objectfastpath(String name, boolean resulttype, FastpathArg[] args)
     Send a function call to the PostgreSQL backend by name.
public  byte[]getData(String name, FastpathArg[] args)
    
public  intgetID(String name)
     This returns the function id associated by its name.
public  intgetInteger(String name, FastpathArg[] args)
    
public  longgetOID(String name, FastpathArg[] args)
     This convenience method assumes that the return value is an oid.


Constructor Detail
Fastpath
public Fastpath(BaseConnection conn)(Code)
Initialises the fastpath system
Parameters:
  conn - BaseConnection to attach to




Method Detail
addFunction
public void addFunction(String name, int fnid)(Code)
This adds a function to our lookup table.

User code should use the addFunctions method, which is based upon a query, rather than hard coding the oid. The oid for a function is not guaranteed to remain static, even on different servers of the same version.
Parameters:
  name - Function name
Parameters:
  fnid - Function id




addFunctions
public void addFunctions(ResultSet rs) throws SQLException(Code)
This takes a ResultSet containing two columns. Column 1 contains the function name, Column 2 the oid.

It reads the entire ResultSet, loading the values into the function table.

REMEMBER to close() the resultset after calling this!!

Implementation note about function name lookups:

PostgreSQL stores the function id's and their corresponding names in the pg_proc table. To speed things up locally, instead of querying each function from that table when required, a Hashtable is used. Also, only the function's required are entered into this table, keeping connection times as fast as possible.

The org.postgresql.largeobject.LargeObject class performs a query upon it's startup, and passes the returned ResultSet to the addFunctions() method here.

Once this has been done, the LargeObject api refers to the functions by name.

Dont think that manually converting them to the oid's will work. Ok, they will for now, but they can change during development (there was some discussion about this for V7.0), so this is implemented to prevent any unwarranted headaches in the future.
Parameters:
  rs - ResultSet
exception:
  SQLException - if a database-access error occurs.
See Also:   org.postgresql.largeobject.LargeObjectManager




createOIDArg
public static FastpathArg createOIDArg(long oid)(Code)
Creates a FastpathArg with an oid parameter. This is here instead of a constructor of FastpathArg because the constructor can't tell the difference between an long that's really int8 and a long thats an oid.



fastpath
public Object fastpath(int fnId, boolean resultType, FastpathArg[] args) throws SQLException(Code)
Send a function call to the PostgreSQL backend
Parameters:
  fnId - Function id
Parameters:
  resultType - True if the result is an integer, false for other results
Parameters:
  args - FastpathArguments to pass to fastpath null if no data, Integer if an integer result, or byte[] otherwise
exception:
  SQLException - if a database-access error occurs.



fastpath
public Object fastpath(String name, boolean resulttype, FastpathArg[] args) throws SQLException(Code)
Send a function call to the PostgreSQL backend by name. Note: the mapping for the procedure name to function id needs to exist, usually to an earlier call to addfunction(). This is the prefered method to call, as function id's can/may change between versions of the backend. For an example of how this works, refer to org.postgresql.largeobject.LargeObject
Parameters:
  name - Function name
Parameters:
  resulttype - True if the result is an integer, false for otherresults
Parameters:
  args - FastpathArguments to pass to fastpath null if no data, Integer if an integer result, or byte[] otherwise
exception:
  SQLException - if name is unknown or if a database-access erroroccurs.
See Also:   org.postgresql.largeobject.LargeObject



getData
public byte[] getData(String name, FastpathArg[] args) throws SQLException(Code)
This convenience method assumes that the return value is not an Integer
Parameters:
  name - Function name
Parameters:
  args - Function arguments byte[] array containing result
exception:
  SQLException - if a database-access error occurs or no result



getID
public int getID(String name) throws SQLException(Code)
This returns the function id associated by its name.

If addFunction() or addFunctions() have not been called for this name, then an SQLException is thrown.
Parameters:
  name - Function name to lookup Function ID for fastpath call
exception:
  SQLException - is function is unknown.




getInteger
public int getInteger(String name, FastpathArg[] args) throws SQLException(Code)
This convenience method assumes that the return value is an Integer
Parameters:
  name - Function name
Parameters:
  args - Function arguments integer result
exception:
  SQLException - if a database-access error occurs or no result



getOID
public long getOID(String name, FastpathArg[] args) throws SQLException(Code)
This convenience method assumes that the return value is an oid.
Parameters:
  name - Function name
Parameters:
  args - Function arguments
exception:
  SQLException - if a database-access error occurs or no result



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.