Source Code Cross Referenced for Driver_PostgreSQL.java in  » RSS-RDF » Jena-2.5.5 » com » hp » hpl » jena » db » impl » 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 » RSS RDF » Jena 2.5.5 » com.hp.hpl.jena.db.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  (c) Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
003:         *  All rights reserved.
004:         *
005:         *
006:         */
007:
008:        package com.hp.hpl.jena.db.impl;
009:
010:        import java.sql.PreparedStatement;
011:        import java.sql.SQLException;
012:
013:        import com.hp.hpl.jena.db.IDBConnection;
014:        import com.hp.hpl.jena.db.RDFRDBException;
015:
016:        /**
017:         * @author hkuno based on code by Dave Reynolds
018:         *
019:         * Extends DriverRDB with PostgreSQL-specific parameters.
020:         */
021:        public class Driver_PostgreSQL extends DriverRDB {
022:
023:            /** The name of the database type this driver supports */
024:
025:            /** 
026:             * Constructor
027:             */
028:            public Driver_PostgreSQL() {
029:                super ();
030:
031:                String myPackageName = this .getClass().getPackage().getName();
032:
033:                DATABASE_TYPE = "PostgreSQL";
034:                DRIVER_NAME = "org.postgresql.Driver";
035:
036:                ID_SQL_TYPE = "INTEGER";
037:                URI_COMPRESS = false;
038:                INDEX_KEY_LENGTH_MAX = INDEX_KEY_LENGTH = 250;
039:                LONG_OBJECT_LENGTH_MAX = LONG_OBJECT_LENGTH = 250;
040:                TABLE_NAME_LENGTH_MAX = 63;
041:                IS_XACT_DB = true;
042:                PRE_ALLOCATE_ID = true;
043:                SKIP_DUPLICATE_CHECK = false;
044:                SQL_FILE = "etc/postgresql.sql";
045:                QUOTE_CHAR = '\'';
046:                DB_NAMES_TO_UPPER = false;
047:                setTableNames(TABLE_NAME_PREFIX);
048:
049:                m_psetClassName = myPackageName + ".PSet_TripleStore_RDB";
050:                m_psetReifierClassName = myPackageName + ".PSet_ReifStore_RDB";
051:
052:                m_lsetClassName = myPackageName
053:                        + ".SpecializedGraph_TripleStore_RDB";
054:                m_lsetReifierClassName = myPackageName
055:                        + ".SpecializedGraphReifier_RDB";
056:            }
057:
058:            /**
059:             * Set the database connection
060:             */
061:            public void setConnection(IDBConnection dbcon) {
062:                m_dbcon = dbcon;
063:
064:                try {
065:                    // Properties defaultSQL = SQLCache.loadSQLFile(DEFAULT_SQL_FILE, null, ID_SQL_TYPE);
066:                    // m_sql = new SQLCache(SQL_FILE, defaultSQL, dbcon, ID_SQL_TYPE);
067:                    m_sql = new SQLCache(SQL_FILE, null, dbcon, ID_SQL_TYPE);
068:                } catch (Exception e) {
069:                    e.printStackTrace(System.err);
070:                    logger.error("Unable to set connection for Driver:", e);
071:                }
072:            }
073:
074:            /**
075:             * Allocate an identifier for a new graph.
076:             *
077:             */
078:            public int graphIdAlloc(String graphName) {
079:                DBIDInt result = null;
080:                int dbid = 0;
081:                try {
082:                    dbid = getInsertID(GRAPH_TABLE);
083:                    PreparedStatement ps = m_sql.getPreparedSQLStatement(
084:                            "insertGraph", GRAPH_TABLE);
085:                    ps.setInt(1, dbid);
086:                    ps.setString(2, graphName);
087:                    ps.executeUpdate();
088:                } catch (SQLException e) {
089:                    throw new RDFRDBException(
090:                            "Failed to get last inserted ID: " + e);
091:                }
092:                return dbid;
093:            }
094:
095:            /**
096:             * Dellocate an identifier for a graph.
097:             *
098:             */
099:            public void graphIdDealloc(int graphId) {
100:                DBIDInt result = null;
101:                try {
102:                    PreparedStatement ps = m_sql.getPreparedSQLStatement(
103:                            "deleteGraph", GRAPH_TABLE);
104:                    ps.setInt(1, graphId);
105:                    ps.executeUpdate();
106:                } catch (SQLException e) {
107:                    throw new RDFRDBException("Failed to delete graph ID: " + e);
108:                }
109:                return;
110:            }
111:
112:            //รณ Now common code moved to DriverRDB - delete this anytime after Jena 2.5.2
113:            //	public int getInsertID ( String tableName ) {
114:            //		DBIDInt result = null;
115:            //		try {
116:            //			PreparedStatement ps = m_sql.getPreparedSQLStatement("getInsertID",tableName);
117:            //			ResultSet rs = ps.executeQuery();
118:            //			if (rs.next()) {
119:            //				result = wrapDBID(rs.getObject(1));
120:            //			} else
121:            //				throw new RDFRDBException("No insert ID");
122:            //		} catch (SQLException e) {
123:            //			throw new RDFRDBException("Failed to insert ID: " + e);
124:            //		}
125:            //		return result.getIntID();
126:            //	}
127:
128:            /**
129:             * Return the parameters for table creation.
130:             * 1) column type for subj, prop, obj.
131:             * 2) column type for head.
132:             * 3) table and index name prefix.
133:             * @param param array to hold table creation parameters. 
134:             */
135:            protected void getTblParams(String[] param) {
136:                String spoColType;
137:                String headColType;
138:
139:                if (LONG_OBJECT_LENGTH > 4000)
140:                    throw new RDFRDBException("Long object length specified ("
141:                            + LONG_OBJECT_LENGTH
142:                            + ") exceeds maximum sane length of 4000.");
143:                if (INDEX_KEY_LENGTH > 4000)
144:                    throw new RDFRDBException("Index key length specified ("
145:                            + INDEX_KEY_LENGTH
146:                            + ") exceeds maximum sane length of 4000.");
147:
148:                spoColType = "VARCHAR(" + LONG_OBJECT_LENGTH + ")";
149:                STRINGS_TRIMMED = false;
150:                param[0] = spoColType;
151:                headColType = "VARCHAR(" + INDEX_KEY_LENGTH + ")";
152:                STRINGS_TRIMMED = false;
153:                param[1] = headColType;
154:                param[2] = TABLE_NAME_PREFIX;
155:            }
156:
157:            /**
158:             * 
159:             * Return the parameters for database initialization.
160:             */
161:            protected String[] getDbInitTablesParams() {
162:                String[] res = new String[3];
163:
164:                getTblParams(res);
165:                EOS_LEN = EOS.length();
166:
167:                return res;
168:            }
169:
170:            /**
171:             * 
172:             * Return the parameters for table creation.
173:             * Generate the table name by counting the number of existing
174:             * tables for the graph. This is not reliable if another client
175:             * is concurrently trying to create a table so, if failure, we
176:             * make several attempts to create the table.
177:             */
178:
179:            protected String[] getCreateTableParams(int graphId, boolean isReif) {
180:                String[] parms = new String[3];
181:                String[] res = new String[2];
182:
183:                getTblParams(parms);
184:                int tblCnt = getTableCount(graphId);
185:                res[0] = genTableName(graphId, tblCnt, isReif);
186:                res[1] = parms[0];
187:                return res;
188:            }
189:
190:            public String genSQLStringMatchOp_IC(String fun) {
191:                return "I" + genSQLLikeKW();
192:            }
193:
194:        }
195:
196:        /*
197:         *  (c) Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
198:         *  All rights reserved.
199:         *
200:         * Redistribution and use in source and binary forms, with or without
201:         * modification, are permitted provided that the following conditions
202:         * are met:
203:         * 1. Redistributions of source code must retain the above copyright
204:         *    notice, this list of conditions and the following disclaimer.
205:         * 2. Redistributions in binary form must reproduce the above copyright
206:         *    notice, this list of conditions and the following disclaimer in the
207:         *    documentation and/or other materials provided with the distribution.
208:         * 3. The name of the author may not be used to endorse or promote products
209:         *    derived from this software without specific prior written permission.
210:
211:         * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
212:         * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
213:         * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
214:         * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
215:         * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
216:         * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
217:         * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
218:         * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
219:         * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
220:         * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
221:         */
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.