|                                                                                                              1
 24
 25  package com.mckoi.database;
 26
 27  import java.sql.Connection
  ; 28  import java.sql.SQLException
  ; 29  import com.mckoi.database.jdbc.MConnection;
 30  import com.mckoi.database.jdbc.DatabaseCallBack;
 31  import com.mckoi.database.jdbc.DatabaseInterface;
 32  import com.mckoi.database.jdbcserver.AbstractJDBCDatabaseInterface;
 33
 34
 42
 43  class InternalJDBCHelper {
 44
 45
 57    static Connection
  createJDBCConnection(User user, 58                                           DatabaseConnection connection) {
 59      InternalDatabaseInterface db_interface =
 60                               new InternalDatabaseInterface(user, connection);
 61      return new InternalConnection(connection, db_interface, 11, 4092000);
 62    }
 63
 64
 71    static void disposeJDBCConnection(Connection
  jdbc_connection) 72                                                           throws SQLException
  { 73      InternalConnection connection = (InternalConnection) jdbc_connection;
 74          connection.internalClose();
 76    }
 77
 78
 79
 80
 82
 93    private static class InternalConnection extends MConnection {
 94
 95
 98      private InternalDatabaseInterface internal_db_interface;
 99
 100
 103     public InternalConnection(DatabaseConnection db,
 104                               InternalDatabaseInterface jdbc_interface,
 105                               int cache_size, int max_size) {
 106       super("", jdbc_interface, cache_size, max_size);
 107       internal_db_interface = jdbc_interface;
 108       setCaseInsensitiveIdentifiers(db.isInCaseInsensitiveMode());
 109     }
 110
 111
 115     InternalDatabaseInterface getDBInterface() {
 116       return internal_db_interface;
 117     }
 118
 119
 123     public void setAutoCommit(boolean status) throws SQLException
  { 124       if (status == true) {
 125         throw new SQLException
  ( 126                "Auto-commit can not be enabled for an internal connection.");
 127       }
 128     }
 129
 130
 134     public boolean getAutoCommit() throws SQLException
  { 135       return false;
 136     }
 137
 138
 146     public void close() {
 147                 }
 150
 151   }
 152
 153
 159   private static class InternalDatabaseInterface
 160                                      extends AbstractJDBCDatabaseInterface {
 161
 162
 165     private DatabaseConnection database;
 166
 167
 170     public InternalDatabaseInterface(User user, DatabaseConnection db) {
 171       super(db.getDatabase());
 172       this.database = db;
 173       init(user, db);
 174     }
 175
 176
 178     public boolean login(String
  default_schema, 179                          String
  username, String  password, 180                          DatabaseCallBack call_back) throws SQLException
  { 181             throw new SQLException
  ( 183                   "'login' is not supported for InterfaceDatabaseInterface");
 184     }
 185
 186     public void dispose() throws SQLException
  { 187       internalDispose();
 188     }
 189
 190   }
 191
 192 }
 193
                                                                                                                                                                                                             |                                                                       
 
 
 
 
 
                                                                                   Popular Tags                                                                                                                                                                                              |