1 24 25 package com.mckoi.database.jdbc; 26 27 import java.sql.*; 28 29 42 43 public final class MckoiConnection { 44 45 48 private MConnection connection; 49 50 53 public MckoiConnection(Connection connection) { 54 if (connection instanceof MConnection) { 55 this.connection = (MConnection) connection; 56 } 57 else { 58 throw new Error ("Can only wrap a Mckoi Database JDBC connection."); 59 } 60 } 61 62 71 public void setStrictGetObject(boolean status) { 72 connection.setStrictGetObject(status); 73 } 74 75 82 public void setVerboseColumnNames(boolean status) { 83 connection.setVerboseColumnNames(status); 84 } 85 86 98 public void addTriggerListener(String trigger_name, 99 TriggerListener trigger_listener) { 100 connection.addTriggerListener(trigger_name, trigger_listener); 101 } 102 103 112 public void removeTriggerListener(String trigger_name, 113 TriggerListener trigger_listener) { 114 connection.removeTriggerListener(trigger_name, trigger_listener); 115 } 116 117 118 120 143 public static String quote(String java_string) { 144 StringBuffer buf = new StringBuffer (); 145 int str_len = java_string.length(); 146 for (int i = 0; i < str_len; ++i) { 147 char c = java_string.charAt(i); 148 if (c == '\'' || c == '\\') { 149 buf.append('\\'); 150 } 151 if (c == '\n') { 152 buf.append("\\n"); 153 } 154 else if (c == '\r') { 155 buf.append("\\r"); 156 } 157 else if (c == '\t') { 158 buf.append("\\t"); 159 } 160 else { 161 buf.append(c); 162 } 163 } 164 return new String (buf); 165 } 166 167 } 168 | Popular Tags |