1 package org.apache.torque.adapter;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 import java.sql.Connection;
20 import java.sql.SQLException;
21
22 /***
23 * This is used to connect to PostgresQL databases.
24 *
25 * <a href="http://www.postgresql.org/">http://www.postgresql.org/</a>
26 *
27 * @author <a href="mailto:hakan42@gmx.de">Hakan Tandogan</a>
28 * @version $Id: DBPostgres.java,v 1.17 2004/02/22 06:19:07 jmcnally Exp $
29 */
30 public class DBPostgres extends DB
31 {
32 /***
33 * Empty constructor.
34 */
35 protected DBPostgres()
36 {
37 }
38
39 /***
40 * This method is used to ignore case.
41 *
42 * @param in The string to transform to upper case.
43 * @return The upper case string.
44 */
45 public String toUpperCase(String in)
46 {
47 String s = new StringBuffer("UPPER(").append(in).append(")").toString();
48 return s;
49 }
50
51 /***
52 * This method is used to ignore case.
53 *
54 * @param in The string whose case to ignore.
55 * @return The string in a case that can be ignored.
56 */
57 public String ignoreCase(String in)
58 {
59 String s = new StringBuffer("UPPER(").append(in).append(")").toString();
60 return s;
61 }
62
63 /***
64 * @see org.apache.torque.adapter.DB#getIDMethodType()
65 */
66 public String getIDMethodType()
67 {
68 return AUTO_INCREMENT;
69 }
70
71 /***
72 * @param name The name of the field (should be of type
73 * <code>String</code>).
74 * @return SQL to retreive the next database key.
75 * @see org.apache.torque.adapter.DB#getIDMethodSQL(Object)
76 */
77 public String getIDMethodSQL(Object name)
78 {
79 return ("select currval('" + name + "')");
80 }
81
82 /***
83 * Locks the specified table.
84 *
85 * @param con The JDBC connection to use.
86 * @param table The name of the table to lock.
87 * @exception SQLException No Statement could be created or executed.
88 */
89 public void lockTable(Connection con, String table) throws SQLException
90 {
91 }
92
93 /***
94 * Unlocks the specified table.
95 *
96 * @param con The JDBC connection to use.
97 * @param table The name of the table to unlock.
98 * @exception SQLException No Statement could be created or executed.
99 */
100 public void unlockTable(Connection con, String table) throws SQLException
101 {
102 }
103
104 /***
105 * This method is used to chek whether the database natively
106 * supports limiting the size of the resultset.
107 *
108 * @return True.
109 */
110 public boolean supportsNativeLimit()
111 {
112 return true;
113 }
114
115 /***
116 * This method is used to chek whether the database natively
117 * supports returning results starting at an offset position other
118 * than 0.
119 *
120 * @return True.
121 */
122 public boolean supportsNativeOffset()
123 {
124 return true;
125 }
126
127 /***
128 * This method is used to chek whether the database supports
129 * limiting the size of the resultset.
130 *
131 * @return LIMIT_STYLE_POSTGRES.
132 */
133 public int getLimitStyle()
134 {
135 return DB.LIMIT_STYLE_POSTGRES;
136 }
137
138 /***
139 * Override the default behavior to associate b with null?
140 *
141 * @see DB#getBooleanString(Boolean)
142 */
143 public String getBooleanString(Boolean b)
144 {
145 return (b == null) ? "0" : (Boolean.TRUE.equals(b) ? "1" : "0");
146 }
147 }