001package com.hfg.sql.jdbc; 002 003 004import com.hfg.security.LoginCredentials; 005import com.hfg.sql.SQLQuery; 006import com.hfg.sql.table.DatabaseCol; 007import com.hfg.sql.table.DatabaseSequence; 008 009import java.sql.Connection; 010import java.sql.SQLException; 011import java.text.DateFormat; 012import java.time.format.DateTimeFormatter; 013 014//------------------------------------------------------------------------------ 015/** 016 * Relational database management system. 017 * @author J. Alex Taylor, hairyfatguy.com 018 */ 019//------------------------------------------------------------------------------ 020// com.hfg Library 021// 022// This library is free software; you can redistribute it and/or 023// modify it under the terms of the GNU Lesser General Public 024// License as published by the Free Software Foundation; either 025// version 2.1 of the License, or (at your option) any later version. 026// 027// This library is distributed in the hope that it will be useful, 028// but WITHOUT ANY WARRANTY; without even the implied warranty of 029// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 030// Lesser General Public License for more details. 031// 032// You should have received a copy of the GNU Lesser General Public 033// License along with this library; if not, write to the Free Software 034// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 035// 036// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com 037// jataylor@hairyfatguy.com 038//------------------------------------------------------------------------------ 039 040public abstract class RDBMS 041{ 042 private String mName; 043 private int mDefaultPort; 044 private int mMaxIdentifierLength; 045 private int mMaxInClauseArgs; 046 private String mDriverClassname; 047 048 public static final RDBMS PostgreSQL = com.hfg.sql.jdbc.postgresql.PostgreSQL.getInstance(); 049 050 051 //########################################################################### 052 // CONSTRUCTORS 053 //########################################################################### 054 055 //--------------------------------------------------------------------------- 056 protected RDBMS(String inName) 057 { 058 mName = inName; 059 } 060 061 062 //########################################################################### 063 // PUBLIC METHODS 064 //########################################################################### 065 066 //-------------------------------------------------------------------------- 067 public String name() 068 { 069 return mName; 070 } 071 072 //-------------------------------------------------------------------------- 073 @Override 074 public String toString() 075 { 076 return name(); 077 } 078 079 //--------------------------------------------------------------------------- 080 public int getMaxIdentifierLength() 081 { 082 return mMaxIdentifierLength; 083 } 084 085 //--------------------------------------------------------------------------- 086 public int getMaxInClauseArgs() 087 { 088 return mMaxInClauseArgs; 089 } 090 091 //--------------------------------------------------------------------------- 092 public int getDefaultPort() 093 { 094 return mDefaultPort; 095 } 096 097 //--------------------------------------------------------------------------- 098 public String getDriverClassName() 099 { 100 return mDriverClassname; 101 } 102 103 //--------------------------------------------------------------------------- 104 public abstract String getConnectString(JDBCServer inServer, String inDatabaseName); 105 106 //--------------------------------------------------------------------------- 107 public abstract String getConnectString(JDBCServer inServer, String inDatabaseName, JDBCConnectionSettings inSettings); 108 109 //--------------------------------------------------------------------------- 110 public abstract JDBCConnectionPool establishConnectionPool(JDBCServer inServer, String inDatabaseName, LoginCredentials inCredentials, JDBCConnectionPoolSettings inPoolSettings); 111 112 113 //--------------------------------------------------------------------------- 114 @Deprecated 115 public abstract DateFormat getSQLDateFormat(int inSQLType); 116 117 //--------------------------------------------------------------------------- 118 public abstract DateTimeFormatter getSQLDateFormatter(int inSQLType); 119 120 //--------------------------------------------------------------------------- 121 public abstract DatabaseSequence allocateSequence(String inName); 122 123 //--------------------------------------------------------------------------- 124 public abstract Long getLastGeneratedId(Connection inConn, DatabaseCol inIdCol) throws SQLException; 125 126 //--------------------------------------------------------------------------- 127 public abstract SQLQuery getConnTestQuery(); 128 129 //--------------------------------------------------------------------------- 130 public abstract boolean tableExists(Connection inConn, Schema inSchema, String inTablename) throws SQLException; 131 132 //########################################################################### 133 // PROTECTED METHODS 134 //########################################################################### 135 136 //--------------------------------------------------------------------------- 137 protected RDBMS setDriverClassName(String inValue) 138 { 139 mDriverClassname = inValue; 140 return this; 141 } 142 143 //--------------------------------------------------------------------------- 144 protected RDBMS setDefaultPort(int inValue) 145 { 146 mDefaultPort = inValue; 147 return this; 148 } 149 150 //--------------------------------------------------------------------------- 151 protected RDBMS setMaxIdentifierLength(int inValue) 152 { 153 mMaxIdentifierLength = inValue; 154 return this; 155 } 156 157 //--------------------------------------------------------------------------- 158 protected RDBMS setMaxInClauseArgs(int inValue) 159 { 160 mMaxInClauseArgs = inValue; 161 return this; 162 } 163 164 //########################################################################### 165 // PRIVATE METHODS 166 //########################################################################### 167 168}