1 64 65 package com.jcorporate.expresso.core.db; 66 67 import com.jcorporate.expresso.core.db.config.JDBCConfig; 68 import com.jcorporate.expresso.core.db.config.JNDIConfig; 69 import com.jcorporate.expresso.core.db.datasource.DSException; 70 import com.jcorporate.expresso.core.db.datasource.JndiDataSource; 71 import com.jcorporate.expresso.core.dbobj.DBField; 72 import com.jcorporate.expresso.core.misc.ConfigManager; 73 import com.jcorporate.expresso.core.misc.ConfigurationException; 74 import com.jcorporate.expresso.core.misc.StringUtil; 75 import com.jcorporate.expresso.kernel.util.ClassLocator; 76 import org.apache.log4j.Logger; 77 78 import java.io.PrintWriter ; 79 import java.sql.CallableStatement ; 80 import java.sql.Connection ; 81 import java.sql.DatabaseMetaData ; 82 import java.sql.DriverManager ; 83 import java.sql.PreparedStatement ; 84 import java.sql.ResultSet ; 85 import java.sql.ResultSetMetaData ; 86 import java.sql.SQLException ; 87 import java.sql.Statement ; 88 import java.util.ArrayList ; 89 import java.util.Date ; 90 import java.util.Enumeration ; 91 import java.util.HashMap ; 92 import java.util.Hashtable ; 93 import java.util.Properties ; 94 import java.util.Vector ; 95 96 97 106 public class DBConnection { 107 108 111 public static final String DEFAULT_DB_CONTEXT_NAME = "default"; 112 113 116 private int connectionId = 0; 117 118 121 private String dbDriverType = ""; 122 123 126 private String dbDriver = ""; 127 128 131 private String dbURL = ""; 132 133 136 private String dbConnectFormat = ""; 137 138 141 private Statement stmnt = null; 142 143 146 private int lastUpdateCount = 0; 147 148 151 private String myDescription = "no description"; 152 153 156 private boolean isConnected = false; 157 158 161 private Connection myConnection; 162 163 166 private EscapeHandler escapeHandler = null; 167 168 171 private PreparedStatement preparedStatement = null; 172 173 176 private CallableStatement callableStatement = null; 177 178 181 private ResultSet myResultSet; 182 183 186 private String strSQL; 187 188 191 private String myLogin = ""; 192 193 196 private String myPassword = ""; 197 198 202 private boolean currentAvailable = false; 203 204 207 private static final String THIS_CLASS = DBConnection 208 .class.getName() + "."; 209 210 213 private long lastTouched = System.currentTimeMillis(); 215 216 219 private long createdTime = System.currentTimeMillis(); 220 221 224 private String dateTimeType = DBField.DATETIME_TYPE; 225 226 229 private boolean immortal = false; 230 231 234 private static Logger log = Logger.getLogger(DBConnection.class); 235 236 241 private static Logger sqlLog = Logger.getLogger("com.jcorporate.expresso.core.db.SQL"); 242 243 246 private String dbName = DEFAULT_DB_CONTEXT_NAME; 247 248 255 public static final int LIMITATION_DISABLED = 0; 256 257 270 public static final int LIMITATION_AFTER_TABLE = 1; 271 272 273 286 public static final int LIMITATION_AFTER_WHERE = 2; 287 288 301 public static final int LIMITATION_AFTER_ORDER_BY = 3; 302 303 316 public static final int LIMITATION_AFTER_SELECT = 4; 317 318 338 private int limitationPosition = LIMITATION_DISABLED; 339 340 341 348 public static final int TRANSACTION_NORMAL_MODE = 1; 349 350 357 public static final int TRANSACTION_DIRTY_MODE = 2; 358 359 366 public static final int TRANSACTION_RESTRICTIVE_MODE = 3; 367 368 375 public static final int TRANSACTION_EXCLUSIVE_MODE = 4; 376 377 378 386 private int transactionCommittedMode = TRANSACTION_NORMAL_MODE; 387 388 396 private int transactionUncommittedMode = TRANSACTION_DIRTY_MODE; 397 398 406 private int transactionRepeatableMode = TRANSACTION_RESTRICTIVE_MODE; 407 408 416 private int transactionSerializableMode = TRANSACTION_EXCLUSIVE_MODE; 417 418 439 private String limitationSyntax = null; 440 441 448 private JDBCConfig myJdbc = null; 449 450 451 454 protected DBConnectionPool parentPool = null; 455 456 488 public DBConnection(String newDBDriver, String newDBURL, 489 String newDBConnectFormat) 490 throws DBException { 491 connectionSetup("manager", newDBDriver, newDBURL, newDBConnectFormat); 492 try { 493 myJdbc = ConfigManager.getJdbcRequired(dbName); 494 } catch (ConfigurationException e) { 495 throw new DBException(e); 496 } 497 } 498 499 500 508 public DBConnection(JDBCConfig newConfigJdbc) throws DBException { 509 if (newConfigJdbc != null) { 510 myJdbc = newConfigJdbc; 511 connectionSetup(newConfigJdbc.getDriverType(), newConfigJdbc.getDriver(), 512 newConfigJdbc.getUrl(), newConfigJdbc.getConnectFormat()); 513 } else { 514 String myName = (THIS_CLASS + 515 "DBConnection(ConfigJdbc)"); 516 throw new DBException(myName + ":ConfigJdbc not initialiazed "); 517 } 518 } 519 520 554 public DBConnection(String newDBDriverType, String newDBDriver, String newDBURL, 555 String newDBConnectFormat) 556 throws DBException { 557 connectionSetup(newDBDriverType, newDBDriver, newDBURL, newDBConnectFormat); 558 try { 559 myJdbc = ConfigManager.getJdbcRequired(dbName); 560 } catch (ConfigurationException e) { 561 throw new DBException(e); 562 } 563 } 564 565 566 576 public void connectionSetup(String newDBDriverType, String newDBDriver, String newDBURL, 577 String newDBConnectFormat) 578 throws DBException { 579 580 dbDriverType = newDBDriverType; 581 dbDriver = newDBDriver; 582 dbURL = newDBURL; 583 dbConnectFormat = newDBConnectFormat; 584 585 try { 586 if (!dbDriverType.equalsIgnoreCase("datasource")) { 587 ClassLocator.loadClass(dbDriver).newInstance(); 588 } 589 590 Properties p = System.getProperties(); 591 p.put("jdbc.drivers", dbDriver); 592 System.setProperties(p); 593 } catch (Exception se) { 594 log.error("Cant find/load the database " + 595 "driver '" + dbDriver, se); 596 String myName = (THIS_CLASS + 597 "DBConnection(String, String, String)"); 598 throw new DBException(myName + ":Cant find/load the database " + 599 "driver '" + dbDriver + "' (" + 600 myDescription + ")"); 601 } 602 603 touch(); 604 605 609 if (log.isDebugEnabled()) { 610 try { 611 if (!dbDriverType.equalsIgnoreCase("datasource")) { 612 DriverManager.setLogWriter(new PrintWriter (java.lang.System.out)); 613 } 614 } catch (java.lang.SecurityException se) { 615 log.warn("Error setting SQL Log stream: ", se); 616 } 617 } 618 } 619 620 623 public void checkTimeOut() 624 throws DBException { 625 if (currentAvailable) { 626 throw new DBException(THIS_CLASS + "checkTimeOut()" + ":Connection '" + getDescription() + 627 "' is not available - it may have timed out and been " + 628 "returned to connection pool. Please try again."); 629 } 630 } 631 632 633 636 public synchronized void clear() 637 throws DBException { 638 if (myResultSet != null) { 639 try { 640 myResultSet.close(); 641 } catch (SQLException ex) { 642 log.warn("Error closing resultset", ex); 643 } 644 myResultSet = null; 645 } 646 if (stmnt != null) { 647 try { 648 stmnt.close(); 649 } catch (SQLException ex) { 650 log.warn("Error closing statement", ex); 651 } 652 stmnt = null; 653 } 654 655 if (preparedStatement != null) { 656 try { 657 preparedStatement.close(); 658 } catch (SQLException ex) { 659 log.warn("Error closing prepared statement", ex); 660 } 661 preparedStatement = null; 662 } 663 664 this.strSQL = null; 665 } 666 667 668 675 public synchronized void commit() 676 throws DBException { 677 678 if (this.supportsTransactions()) { 679 try { 680 myConnection.commit(); 681 } catch (SQLException se) { 682 throw new DBException(THIS_CLASS + "commit():Could not commit (" + 683 myDescription + ")", se.getMessage()); 684 } 685 } 686 687 touch(); 688 } 689 690 691 698 public synchronized void connect(String newLogin, String newPassword) 699 throws DBException { 700 createdTime = System.currentTimeMillis(); 701 myLogin = newLogin.trim(); 702 myPassword = newPassword.trim(); 703 704 if (dbConnectFormat == null) { 705 String myName = (THIS_CLASS + "connect(String, String)"); 706 throw new DBException(myName + 707 ":dbConnectFormat argument cannot " + 708 "be null"); 709 } 710 try { 711 if (dbConnectFormat.equals("1")) { 712 if (log.isDebugEnabled()) { 713 log.debug("Using Connect Format #1: DriverManager.getConnection(" + 714 dbURL + "," + newLogin + "," + newPassword + 715 ");"); 716 } 717 718 myConnection = DriverManager.getConnection(dbURL, newLogin, 719 newPassword); 720 } else if (dbConnectFormat.equals("2")) { 721 myConnection = DriverManager.getConnection(dbURL + "?user=" + 722 newLogin + 723 ";password=" + 724 newPassword); 725 } else if (dbConnectFormat.equals("3")) { 726 Properties props = new Properties (); 727 props.put("user", newLogin); 728 props.put("password", newPassword); 729 myConnection = DriverManager.getConnection(dbURL, props); 730 } else if (dbConnectFormat.equals("4")) { 731 myConnection = DriverManager.getConnection(dbURL + "?user=" + 732 newLogin + 733 "&password=" + 734 newPassword); 735 } else { 736 String myName = (THIS_CLASS + "connect(String, String)"); 737 throw new DBException(myName + ":Unknown dbConnectFormat " + 738 "choice:" + dbConnectFormat); 739 } 740 } catch (SQLException se) { 741 String myName = (THIS_CLASS + "connect(String, String)"); 742 throw new DBException(myName + 743 ":Cant get connection to database via driver '" + 744 dbDriver + "' and URL '" + dbURL + "' (" + 745 myDescription + ")", se.getMessage()); 746 } 747 if (myConnection == null) { 748 String myName = (THIS_CLASS + "connect(String, String)"); 749 throw new DBException(myName + 750 ":Cant get connection to database via driver '" + 751 dbDriver + "' and URL '" + dbURL + 752 ":JDBC returned a null connection. (" + 753 myDescription + ")"); 754 } 755 756 isConnected = true; 758 this.setAutoCommit(true); 759 touch(); 760 } 761 762 771 public synchronized void connect(JndiDataSource newJndiDS) throws DBException { 772 createdTime = System.currentTimeMillis(); 773 myLogin = myJdbc.getLogin().trim(); 774 myPassword = myJdbc.getPassword().trim(); 775 if (parentPool.getJNDIConfig(myJdbc) == null) { 776 String myName = (THIS_CLASS + "connect(JndiDataSource)"); 777 throw new DBException(myName + " JNDI info configure for datasource"); 778 } 779 780 if (dbConnectFormat == null) { 781 String myName = (THIS_CLASS + "connect(JndiDataSource)"); 782 throw new DBException(myName + 783 ":dbConnectFormat argument cannot " + 784 "be null"); 785 } 786 try { 787 if (dbConnectFormat.equals("1")) { 788 if (log.isDebugEnabled()) { 789 log.debug("Using Connect Format #1: Datasource.getConnection(" + 790 dbURL + "," + myLogin + "," + myPassword + 791 ");"); 792 } 793 794 myConnection = newJndiDS.getConnection(); 795 } else { 796 if (dbConnectFormat.equals("2")) { 797 myConnection = newJndiDS.getConnection(myLogin, myPassword); 798 } else { 799 String myName = (THIS_CLASS + "connect(JndiDataSource)"); 800 throw new DBException(myName + ":Unknown dbConnectFormat " + 801 "choice:" + dbConnectFormat); 802 } 803 } 804 } catch (DSException se) { 805 String myName = (THIS_CLASS + "connect(JndiDataSource)"); 806 throw new DBException(myName + 807 ":Cannot get connection to database via JNDI DataSource '" + 808 dbURL + "' (" + 809 myDescription + ")", se.getMessage()); 810 } 811 if (myConnection == null) { 812 String myName = (THIS_CLASS + "connect(JndiDataSource)"); 813 throw new DBException(myName + 814 ":Cannot get connection to database via JNDI DataSource '" + 815 "' URL '" + dbURL + 816 ":JNDI JDBC returned a null connection. (" + 817 myDescription + ")"); 818 } 819 820 isConnected = true; 822 this.setAutoCommit(true); 823 touch(); 824 } 825 826 832 public Statement createStatement() { 833 try { 834 if (myConnection == null) { 835 return null; 836 } 837 838 stmnt = myConnection.createStatement(); 839 840 return stmnt; 841 } catch (SQLException e) { 842 log.error(e); 843 } 844 845 return stmnt; 846 } 847 848 855 public PreparedStatement createPreparedStatement(String sqlString) { 856 try { 857 if (myConnection == null) { 858 return null; 859 } 860 touch(); 861 862 if (preparedStatement != null) { 863 try { 864 preparedStatement.close(); 865 } catch (SQLException ex) { 866 log.warn("Error closing older prepared statement: ", ex); 867 } 868 } 869 870 if (sqlLog.isDebugEnabled()) { 871 sqlLog.debug("Connection " + getId() + " preparing statement from:'" + sqlString + 872 "' on db '" + getDataContext() + "'"); 873 } 874 875 preparedStatement = myConnection.prepareStatement(sqlString); 876 } catch (SQLException e) { 877 log.error(e); 878 } 879 return preparedStatement; 880 } 881 882 885 public void clearPreparedStatement() { 886 if (this.preparedStatement != null) { 887 try { 888 preparedStatement.close(); 889 } catch (SQLException ex) { 890 log.warn("Error clearing prepared statement", ex); 891 } 892 893 preparedStatement = null; 894 } 895 } 896 897 904 public CallableStatement createCallableStatement(String sqlString) { 905 try { 906 if (myConnection == null) { 907 return null; 908 } 909 touch(); 910 911 if (callableStatement != null) { 912 try { 913 callableStatement.close(); 914 } catch (SQLException ex) { 915 log.warn("Error closing older callable statement: ", ex); 916 } 917 } 918 callableStatement = myConnection.prepareCall(sqlString); 919 } catch (SQLException e) { 920 log.error(e); 921 } 922 return callableStatement; 923 } 924 925 926 929 public void clearCallableStatement() { 930 if (this.callableStatement != null) { 931 try { 932 callableStatement.close(); 933 } catch (SQLException ex) { 934 log.warn("Error clearing callable statement", ex); 935 } 936 937 callableStatement = null; 938 } 939 } 940 941 942 947 public synchronized void disconnect() 948 throws DBException { 949 try { 950 try { 951 clear(); 952 } catch (DBException ex) { 953 log.error("Error clearing connection", ex); 954 } 955 if (isConnected) { 956 try { 957 if (myConnection.getAutoCommit() == false) { 958 myConnection.rollback(); 960 } 961 } catch (SQLException ex) { 962 log.error("Error commiting connection when closing"); 963 } 964 965 myConnection.close(); 966 } 967 968 } catch (SQLException se) { 969 throw new DBException(THIS_CLASS + "disconnect()" + ":Could not commit/close:" + " (" + 970 myDescription + ")", se.getMessage()); 971 } 972 973 if (!isConnected) { 974 log.warn(THIS_CLASS + "disconnect()" + ":Connection already closed (" + myDescription + 975 ")"); 976 } 977 978 myConnection = null; 979 isConnected = false; 980 immortal = false; 981 } 982 983 984 991 public synchronized void execute() 992 throws DBException { 993 touch(); 994 995 if (!isConnected) { 996 throw new DBException("Not connected to database " + 997 "- called connect method first (" + 998 myDescription + ", db/context '" + 999 getDataContext() + "')"); 1000 } 1001 1002 checkTimeOut(); 1003 1004 try { 1005 if (myConnection == null) { 1006 throw new DBException("No current connection - " + 1007 "connect to database failed: Unable to execute query:" + 1008 strSQL + " (" + myDescription + 1009 ", db/context '" + getDataContext() + "')"); 1010 } 1011 1012 if (myResultSet != null) { 1017 try { 1018 myResultSet.close(); 1019 } catch (SQLException ex) { 1020 log.warn("Error closing resultset", ex); 1021 } 1022 myResultSet = null; 1023 } 1024 1025 if (stmnt != null) { 1026 try { 1027 stmnt.close(); 1028 } catch (SQLException ex) { 1029 log.warn("Error closing statement", ex); 1030 } 1031 stmnt = null; 1032 } 1033 1034 1035 if (preparedStatement == null && strSQL != null && strSQL.length() > 0) { 1041 stmnt = myConnection.createStatement(); 1042 1043 if (stmnt == null) { 1044 throw new DBException("createStatement() returned " + 1045 "null statement - unable to execute query:" + 1046 strSQL + " (" + myDescription + 1047 ", db/context '" + getDataContext() + "')"); 1048 } 1049 if (sqlLog.isDebugEnabled()) { 1050 sqlLog.debug("Connection " + getId() + " Executing:'" + strSQL + 1051 "' on db '" + getDataContext() + "'"); 1052 } 1053 1054 myResultSet = stmnt.executeQuery(strSQL); 1055 lastUpdateCount = stmnt.getUpdateCount(); 1056 } else { 1057 if (sqlLog.isDebugEnabled()) { 1058 sqlLog.debug("Connection " + getId() + " Executing: preparedStatement" + 1059 " on db '" + getDataContext() + "'"); 1060 } 1061 myResultSet = preparedStatement.executeQuery(); 1062 } 1063 1064 long endTimer = System.currentTimeMillis(); 1065 if (log.isDebugEnabled()) { 1066 String pre = strSQL; 1067 if (preparedStatement != null) { 1068 pre = " prepared statement"; 1069 } 1070 String msg = "Time to execute" + pre + " was " + 1071 (endTimer - getLastTouched()) + 1072 " milliseconds"; 1073 log.debug(msg); 1074 } 1075 if (sqlLog.isDebugEnabled()) { 1076 String pre = ""; 1077 if (preparedStatement != null) { 1078 pre = " prepared statement"; 1079 } 1080 String msg = "Time to execute" + pre + " was " + 1081 (endTimer - getLastTouched()) + 1082 " milliseconds"; 1083 sqlLog.debug(msg); 1084 } 1085 } catch (SQLException se) { 1086 if (strSQL == null) { 1087 strSQL = "[Prepared Statement]"; 1088 } 1089 throw new DBException("Unable to execute statement: " + strSQL + 1090 " (" + myDescription + ", db/context '" + 1091 getDataContext() + "')", se); 1092 } 1093 } 1094 1095 1096 1103 public synchronized void execute(String theSQL) 1104 throws DBException { 1105 touch(); 1106 setSQL(theSQL); 1107 execute(); 1108 } 1109 1110 1111 1120 public synchronized void executeUpdate(String theSQL) 1121 throws DBException { 1122 touch(); 1123 1124 if (!isConnected) { 1125 throw new DBException("Not connected - please call " + 1126 "connect method first (" + myDescription + 1127 ", db/context '" + getDataContext() + "')"); 1128 } 1129 1130 strSQL = theSQL; 1131 1132 if (myConnection == null) { 1133 throw new DBException("Not connected (null connection) " + " (" + 1134 myDescription + ", db/context '" + 1135 getDataContext() + "')"); 1136 } 1137 1138 checkTimeOut(); 1139 1140 try { 1141 if (myResultSet != null) { 1142 try { 1143 myResultSet.close(); 1144 } catch (SQLException ex) { 1145 log.warn("Error closing resultset", ex); 1146 } 1147 myResultSet = null; 1148 } 1149 if (stmnt != null) { 1150 try { 1151 stmnt.close(); 1152 } catch (SQLException ex) { 1153 log.warn("Error closing stmnt"); 1154 } 1155 stmnt = null; 1156 } 1157 1158 if (preparedStatement == null && strSQL != null && strSQL.length() > 0) { 1159 stmnt = myConnection.createStatement(); 1160 1161 if (stmnt == null) { 1162 throw new DBException("Null statement returned " + 1163 "from createStatement call (" + 1164 myDescription + ", db/context '" + 1165 getDataContext() + "')"); 1166 } 1167 1168 if (sqlLog.isDebugEnabled()) { 1169 sqlLog.debug("Executing update:" + strSQL); 1170 } 1171 lastUpdateCount = stmnt.executeUpdate(strSQL); 1172 } else { 1173 if (sqlLog.isDebugEnabled()) { 1174 sqlLog.debug("Executing update (prepared):"); 1175 } 1176 lastUpdateCount = preparedStatement.executeUpdate(); 1177 } 1178 1179 long endTimer = System.currentTimeMillis(); 1180 if (log.isDebugEnabled()) { 1181 log.debug("Update '" + strSQL + "' took " + 1182 (endTimer - getLastTouched()) + 1183 " milliseconds"); 1184 } 1185 if (sqlLog.isDebugEnabled()) { 1186 sqlLog.debug("Updated:" + lastUpdateCount + " records in " + 1187 (endTimer - getLastTouched()) + 1188 " milliseconds"); 1189 } 1190 } catch (SQLException se) { 1191 String errMsg; 1192 if (strSQL == null) { 1193 errMsg = se.getMessage(); 1194 } else { 1195 errMsg = "Unable to execute statement: " + strSQL + 1196 "(" + myDescription + ", db/context '" + 1197 getDataContext() + "') for reason: " + se.getMessage(); 1198 } 1199 throw new DBException(errMsg, se); 1200 } 1201 } 1202 1203 1204 1211 public synchronized void executeProcedure() 1212 throws DBException { 1213 long beginTimer = 0; 1214 touch(); 1215 1216 if (!isConnected) { 1217 throw new DBException("Not connected to database " + 1218 "- called connect method first (" + 1219 myDescription + ", db/context '" + 1220 getDataContext() + "')"); 1221 } 1222 1223 checkTimeOut(); 1224 1225 try { 1226 if (myConnection == null) { 1227 throw new DBException("No current connection - " + 1228 "connect to database failed: Unable to execute query:" + 1229 "callableStatment" + " (" + myDescription + 1230 ", db/context '" + getDataContext() + "')"); 1231 } 1232 1233 if (myResultSet != null) { 1238 try { 1239 myResultSet.close(); 1240 } catch (SQLException ex) { 1241 log.warn("Error closing resultset", ex); 1242 } 1243 myResultSet = null; 1244 } 1245 if (log.isDebugEnabled()) { 1246 beginTimer = System.currentTimeMillis(); 1247 } 1248 1249 if (stmnt != null) { 1250 try { 1251 stmnt.close(); 1252 } catch (SQLException ex) { 1253 log.warn("Error closing statement", ex); 1254 } 1255 stmnt = null; 1256 } 1257 1258 1259 if (callableStatement != null) { 1264 1265 if (sqlLog.isDebugEnabled()) { 1266 sqlLog.debug("Connection " + getId() + " Executing: callableStatement" + 1267 " on db '" + getDataContext() + "'"); 1268 } 1269 1270 myResultSet = callableStatement.executeQuery(); 1272 } else { 1277 throw new DBException("Unable to execute statement: callableStatment" + 1278 " (" + myDescription + ", db/context '" + 1279 getDataContext() + "')"); 1280 } 1281 1282 if (log.isDebugEnabled()) { 1283 long endTimer = System.currentTimeMillis(); 1284 log.debug("Time to execute callableStatment'" + "' was " + 1285 (endTimer - beginTimer) + 1286 " milliseconds"); 1287 } 1288 } catch (SQLException se) { 1289 throw new DBException("Unable to execute statement: callableStatment" + 1290 " (" + myDescription + ", db/context '" + 1291 getDataContext() + "')", se); 1292 } 1293 } 1294 1295 1296 1299 public void finalize() { 1300 try { 1301 if (isConnected) { 1302 disconnect(); 1303 } 1304 } catch (DBException de) { 1305 log.warn("Error disconconnecting connection in finalization"); 1306 } 1307 } 1308 1309 1315 public synchronized boolean first() 1316 throws DBException { 1317 checkTimeOut(); 1318 1319 return next(); 1320 } 1321 1322 1323 1331 public boolean getAutoCommit() 1332 throws DBException { 1333 1334 try { 1335 if (myConnection == null) { 1336 return false; 1337 } else { 1338 return myConnection.getAutoCommit(); 1339 } 1340 } catch (SQLException se) { 1341 throw new DBException(THIS_CLASS + "setAutoCommit(boolean)" + 1342 ":Could not get auto commit setting" + " (" + 1343 myDescription + ")", se.getMessage()); 1344 } 1345 } 1346 1347 1348 1353 public String getCatalog() 1354 throws DBException { 1355 try { 1356 return myConnection.getCatalog(); 1357 } catch (SQLException se) { 1358 throw new DBException(THIS_CLASS + "getCatalog()" + ":Unable to retrieve catalog " + 1359 " for this connection", se.getMessage()); 1360 } 1361 } 1362 1363 1373 public java.sql.Clob getClob(int fieldNum) throws DBException { 1374 checkTimeOut(); 1375 try { 1376 return myResultSet.getClob(fieldNum); 1377 } catch (SQLException ex) { 1378 throw new DBException(THIS_CLASS + "getClob(int)" + ":Error fetching CLOB field " + 1379 fieldNum + " (" + myDescription + ")", 1380 ex.getMessage()); 1381 } 1382 } 1383 1384 1394 public java.sql.Clob getClob(String fieldName) throws DBException { 1395 checkTimeOut(); 1396 try { 1397 return myResultSet.getClob(fieldName); 1398 } catch (SQLException ex) { 1399 throw new DBException(THIS_CLASS + "getClob(String)" + ":Error fetching CLOB field " + 1400 fieldName + " (" + myDescription + ")", 1401 ex.getMessage()); 1402 } 1403 } 1404 1405 1406 1411 public long getCreatedTime() { 1412 return this.createdTime; 1413 } 1414 1415 1422 public java.math.BigDecimal getBigDecimal(int fieldNum) throws DBException { 1423 checkTimeOut(); 1424 try { 1425 return myResultSet.getBigDecimal(fieldNum); 1426 } catch (SQLException se) { 1427 throw new DBException(THIS_CLASS + "getDouble(int)" + ":Error fetching double field " + 1428 fieldNum + " (" + myDescription + ")", 1429 se.getMessage()); 1430 } 1431 } 1432 1433 1443 public java.sql.Blob getBlob(int fieldNum) throws DBException { 1444 checkTimeOut(); 1445 try { 1446 return myResultSet.getBlob(fieldNum); 1447 } catch (SQLException ex) { 1448 throw new DBException(THIS_CLASS + "getBlob(int)" + ":Error fetching BLOB field " + 1449 fieldNum + " (" + myDescription + ")", 1450 ex.getMessage()); 1451 } 1452 } 1453 1454 1464 public java.sql.Blob getBlob(String fieldName) throws DBException { 1465 checkTimeOut(); 1466 try { 1467 return myResultSet.getBlob(fieldName); 1468 } catch (SQLException ex) { 1469 throw new DBException(THIS_CLASS + "getBlob(String)" + ":Error fetching BLOB field " + 1470 fieldName + " (" + myDescription + ")", 1471 ex.getMessage()); 1472 } 1473 } 1474 1475 1482 public java.io.InputStream getBinaryStream(String fieldName) throws DBException { 1483 checkTimeOut(); 1484 try { 1485 return myResultSet.getBinaryStream(fieldName); 1486 } catch (SQLException ex) { 1487 throw new DBException(THIS_CLASS + "getBlob(String)" + ":Error fetching BLOB field " + 1488 fieldName + " (" + myDescription + ")", 1489 ex.getMessage()); 1490 } 1491 } 1492 1493 1494 1501 public java.io.InputStream getBinaryStream(int fieldNum) throws DBException { 1502 checkTimeOut(); 1503 try { 1504 return myResultSet.getBinaryStream(fieldNum); 1505 } catch (SQLException ex) { 1506 throw new DBException(THIS_CLASS + "getBlob(String)" + ":Error fetching BLOB field " + 1507 fieldNum + " (" + myDescription + ")", 1508 ex.getMessage()); 1509 } 1510 } 1511 1512 1513 1520 public byte[] getBytes(int fieldNum) throws DBException { 1521 checkTimeOut(); 1522 try { 1523 return myResultSet.getBytes(fieldNum); 1524 } catch (SQLException ex) { 1525 throw new DBException("Error fetching string field " + fieldNum + 1526 ":Last SQL was:" + strSQL + " (" + 1527 myDescription + ")", ex.getMessage()); 1528 } 1529 } 1530 1531 1532 1538 public String getDateTimeType() { 1539 return dateTimeType; 1540 } 1541 1542 1559 public Connection getConnection() { 1560 if (myConnection == null) { 1561 return null; 1562 } 1563 return myConnection; 1564 } 1565 1566 1567 1574 public String getDBDriver() { 1575 return dbDriver; 1576 } 1577 1578 1583 public DatabaseMetaData getDBMetaData() 1584 throws DBException { 1585 try { 1586 return myConnection.getMetaData(); 1587 } catch (SQLException se) { 1588 throw new DBException(THIS_CLASS + "getDBMetaData()" + ":Unable to retrieve meta-data " + 1589 " for this connection", se.getMessage()); 1590 } 1591 } 1592 1593 1594 1604 public boolean supportsTransactions() 1605 throws DBException { 1606 try { 1607 return myConnection.getMetaData().supportsTransactions(); 1608 } catch (SQLException se) { 1609 throw new DBException("Unable to retrieve meta-data " + 1610 " for this connection", se); 1611 } catch (NullPointerException ex) { 1612 log.error("NPE: Database driver didn't return connection metadata, possibly not connected", ex); 1616 return false; 1617 } 1618 } 1619 1620 1625 public String getDBURL() { 1626 return dbURL; 1627 } 1628 1629 1636 public String getDescription() { 1637 return myDescription; 1638 } 1639 1640 1647 public double getDouble(int fieldNum) 1648 throws DBException { 1649 1650 checkTimeOut(); 1651 1652 try { 1653 return myResultSet.getDouble(fieldNum); 1654 } catch (SQLException se) { 1655 throw new DBException(THIS_CLASS + "getDouble(int)" + ":Error fetching double field " + 1656 fieldNum + " (" + myDescription + ")", 1657 se.getMessage()); 1658 } 1659 } 1660 1661 1662 1672 public Hashtable getFields(String tableName) 1673 throws DBException { 1674 return new Hashtable (getFieldsMap(tableName)); 1675 } 1676 1677 1678 1683 public synchronized EscapeHandler getEscapeHandler() { 1684 return this.escapeHandler; 1685 } 1686 1687 1688 1697 public synchronized HashMap getFieldsMap(String tableName) 1698 throws DBException { 1699 checkTimeOut(); 1700 1701 HashMap allfields = new HashMap (); 1702 1703 try { 1704 1707 if (this.getDBDriver().equals("org.postgresql.Driver")) { 1708 tableName = tableName.toLowerCase(); 1709 } 1710 1711 ResultSet rs = myConnection.getMetaData().getColumns("%", "%", 1712 tableName, 1713 "%"); 1714 1715 while (rs.next()) { 1716 allfields.put(rs.getString(4), rs.getString(6)); 1717 } 1718 1719 } catch (SQLException se) { 1720 throw new DBException(THIS_CLASS + "getFields(String)" + 1721 ":Unable to retrieve column " + 1722 "information (" + myDescription + ")", 1723 se.getMessage()); 1724 } 1725 1726 return allfields; 1727 } 1728 1729 1730 1735 public int getId() { 1736 return connectionId; 1737 } 1738 1739 1744 public boolean getImmortal() { 1745 return immortal; 1746 } 1747 1748 1755 public int getInt(int fieldNum) 1756 throws DBException { 1757 1758 try { 1759 return myResultSet.getInt(fieldNum); 1760 } catch (SQLException se) { 1761 throw new DBException(THIS_CLASS + "getInt(int)" + 1762 ":Error fetching int field " + 1763 fieldNum + " (" + myDescription + ")", 1764 se.getMessage()); 1765 } 1766 } 1767 1768 1769 1778 public long getLastTouched() { 1779 return lastTouched; 1780 } 1781 1782 1790 public synchronized int getLimitationPosition() { 1791 return limitationPosition; 1792 } 1793 1794 1802 synchronized void setLimitationPosition(int pos) 1803 throws DBException { 1804 this.limitationPosition = pos; 1805 } 1806 1807 1814 public synchronized String getLimitationSyntax() { 1815 return limitationSyntax; 1816 } 1817 1818 1827 synchronized void setLimitationSyntax(String syntax) { 1828 this.limitationSyntax = syntax; 1829 } 1830 1831 1836 public String getLogin() { 1837 return myLogin; 1838 } 1839 1840 1847 public long getLong(int fieldNum) 1848 throws DBException { 1849 1850 try { 1851 return myResultSet.getLong(fieldNum); 1852 } catch (SQLException se) { 1853 throw new DBException(THIS_CLASS + "getLong(int)" + 1854 ":Error fetching field " + 1855 fieldNum + " (" + myDescription + ")", 1856 se.getMessage()); 1857 } 1858 } 1859 1860 1865 public synchronized ResultSetMetaData getMetaData() { 1866 if (myResultSet != null) { 1867 try { 1868 return myResultSet.getMetaData(); 1869 } catch (SQLException ex) { 1870 log.error("Unable to retrieve metadata.", ex); 1871 return null; 1872 } 1873 } else { 1874 return null; 1875 } 1876 } 1877 1878 1883 public String getPassword() { 1884 return myPassword; 1885 } 1886 1887 1899 public ResultSet getResultSet() { 1900 return this.myResultSet; 1901 } 1902 1903 1908 public String getSQL() { 1909 return strSQL; 1910 } 1911 1912 1921 public String getString(int fieldNum) 1922 throws DBException { 1923 1924 checkTimeOut(); 1925 1926 if (myResultSet == null) { 1927 throw new DBException("[2]Null ResultSet object (" + myDescription + ")"); 1928 } 1929 try { 1930 String resultValue = myResultSet.getString(fieldNum); 1931 1932 if (resultValue == null) { 1933 return null; 1934 } 1935 1936 return resultValue.trim(); 1937 } catch (SQLException se) { 1938 if (strSQL == null) { 1939 strSQL = ("null"); 1940 } 1941 1942 throw new DBException("Error fetching string field " + fieldNum + ":Last SQL was:" + strSQL + " (" + 1943 myDescription + ")", se.getMessage()); 1944 } 1945 } 1946 1947 1948 1955 public String getStringNoTrim(int fieldNum) 1956 throws DBException { 1957 checkTimeOut(); 1958 1959 if (myResultSet == null) { 1960 throw new DBException("Null ResultSet object (" + myDescription + ")"); 1961 } 1962 try { 1963 String resultValue = myResultSet.getString(fieldNum); 1964 1965 if (resultValue == null) { 1966 return null; 1968 } 1969 1970 return resultValue; 1971 } catch (SQLException se) { 1972 throw new DBException("Error fetching string field " + fieldNum + ":Last SQL was:" + strSQL + " (" + 1973 " (" + myDescription + ")", se.getMessage()); 1974 } 1975 } 1976 1977 1978 1987 public String getString(String fieldName) 1988 throws DBException { 1989 1990 String resultValue = getStringNoTrim(fieldName); 1991 1992 if (resultValue == null) { 1993 return null; 1994 } 1995 1996 return resultValue.trim(); 1997 } 1998 1999 2000 2008 public String getStringNoTrim(String fieldName) 2009 throws DBException { 2010 checkTimeOut(); 2011 2012 if (myResultSet == null) { 2013 throw new DBException("[2]Null ResultSet object (" + myDescription + ")"); 2014 } 2015 try { 2016 String resultValue = myResultSet.getString(fieldName); 2017 2018 if (resultValue == null) { 2019 return null; 2020 } 2021 2022 return resultValue; 2023 } catch (SQLException se) { 2024 if (strSQL == null) { 2025 strSQL = ("null"); 2026 } 2027 2028 throw new DBException("Error fetching string field " + fieldName + ":Last SQL was:" + strSQL + " (" + 2029 myDescription + ")", se.getMessage()); 2030 } 2031 } 2032 2033 2034 2044 public Date getTimestamp(String fieldName) 2045 throws DBException { 2046 checkTimeOut(); 2047 2048 if (myResultSet == null) { 2049 throw new DBException("[2]Null ResultSet object (" + 2050 myDescription + ")"); 2051 } 2052 try { 2053 Date resultValue = myResultSet.getTimestamp(fieldName); 2054 2055 return resultValue; 2056 } catch (SQLException se) { 2057 if (strSQL == null) { 2058 strSQL = ("null"); 2059 } 2060 2061 throw new DBException("Error fetching string field " + fieldName + 2062 ":Last SQL was:" + strSQL + " (" + 2063 myDescription + ")", se.getMessage()); 2064 } 2065 } 2066 2067 2068 2078 public Date getTimestamp(int fieldNum) 2079 throws DBException { 2080 checkTimeOut(); 2081 2082 if (myResultSet == null) { 2083 throw new DBException("[2]Null ResultSet object (" + 2084 myDescription + ")"); 2085 } 2086 try { 2087 Date resultValue = myResultSet.getTimestamp(fieldNum); 2088 2089 return resultValue; 2090 } catch (SQLException se) { 2091 if (strSQL == null) { 2092 strSQL = ("null"); 2093 } 2094 2095 throw new DBException("Error fetching string field " + fieldNum + 2096 ":Last SQL was:" + strSQL + " (" + 2097 myDescription + ")", se.getMessage()); 2098 } 2099 } 2100 2101 2102 2112 public Date getTime(String fieldName) 2113 throws DBException { 2114 checkTimeOut(); 2115 2116 if (myResultSet == null) { 2117 throw new DBException("[2]Null ResultSet object (" + 2118 myDescription + ")"); 2119 } 2120 try { 2121 Date resultValue = myResultSet.getTime(fieldName); 2122 2123 return resultValue; 2124 } catch (SQLException se) { 2125 if (strSQL == null) { 2126 strSQL = ("null"); 2127 } 2128 2129 throw new DBException("Error fetching string field " + fieldName + 2130 ":Last SQL was:" + strSQL + " (" + 2131 myDescription + ")", se.getMessage()); 2132 } 2133 } 2134 2135 2136 2146 public Date getTime(int fieldNum) 2147 throws DBException { 2148 checkTimeOut(); 2149 2150 if (myResultSet == null) { 2151 throw new DBException("[2]Null ResultSet object (" + 2152 myDescription + ")"); 2153 } 2154 try { 2155 Date resultValue = myResultSet.getTime(fieldNum); 2156 2157 return resultValue; 2158 } catch (SQLException se) { 2159 if (strSQL == null) { 2160 strSQL = ("null"); 2161 } 2162 2163 throw new DBException("Error fetching string field " + fieldNum + 2164 ":Last SQL was:" + strSQL + " (" + 2165 myDescription + ")", se.getMessage()); 2166 } 2167 } 2168 2169 2170 2180 public Date getDate(String fieldName) 2181 throws DBException { 2182 checkTimeOut(); 2183 2184 if (myResultSet == null) { 2185 throw new DBException("[2]Null ResultSet object (" + 2186 myDescription + ")"); 2187 } 2188 try { 2189 Date resultValue = myResultSet.getDate(fieldName); 2190 2191 return resultValue; 2192 } catch (SQLException se) { 2193 if (strSQL == null) { 2194 strSQL = ("null"); 2195 } 2196 2197 throw new DBException("Error fetching string field " + fieldName + 2198 ":Last SQL was:" + strSQL + " (" + 2199 myDescription + ")", se.getMessage()); 2200 } 2201 } 2202 2203 2204 2214 public Date getDate(int fieldNum) 2215 throws DBException { 2216 checkTimeOut(); 2217 2218 if (myResultSet == null) { 2219 throw new DBException("[2]Null ResultSet object (" + 2220 myDescription + ")"); 2221 } 2222 try { 2223 Date resultValue = myResultSet.getDate(fieldNum); 2224 2225 return resultValue; 2226 } catch (SQLException se) { 2227 if (strSQL == null) { 2228 strSQL = "null"; 2229 } 2230 2231 throw new DBException("Error fetching string field " + fieldNum + 2232 ":Last SQL was:" + strSQL + " (" + 2233 myDescription + ")", se.getMessage()); 2234 } 2235 } 2236 2237 2238 2245 public Hashtable getTypeMap() { 2246 try { 2247 DatabaseMetaData dm = myConnection.getMetaData(); 2248 ResultSet rsx = dm.getTypeInfo(); 2249 Hashtable theMap = new Hashtable (3); 2250 String oneTypeString = null; 2251 int oneTypeInt = 0; 2252 2253 while (rsx.next()) { 2254 oneTypeString = rsx.getString(1); 2255 oneTypeInt = rsx.getShort(2); 2256 theMap.put(oneTypeString, new Integer (oneTypeInt)); 2257 } 2258 2259 return theMap; 2260 } catch (Exception se) { 2261 return new Hashtable (); 2262 } 2263 } 2264 2265 2271 public int getUpdateCount() { 2272 return lastUpdateCount; 2273 } 2274 2275 2284 public Enumeration getWildCards() { 2285 Vector newChars = new Vector (4); 2286 newChars.addElement(("%")); 2287 newChars.addElement(("_")); 2288 newChars.addElement(("[")); 2289 newChars.addElement(("]")); 2290 2291 return newChars.elements(); 2292 } 2293 2294 2303 public ArrayList getWildCardsList() { 2304 ArrayList newChars = new ArrayList (4); 2305 newChars.add(("%")); 2306 newChars.add(("_")); 2307 newChars.add(("[")); 2308 newChars.add(("]")); 2309 2310 return newChars; 2311 } 2312 2313 2321 public int getTransactionMode() 2322 throws DBException { 2323 try { 2324 int transactionMode = myConnection.getTransactionIsolation(); 2325 switch (transactionMode) { 2326 case Connection.TRANSACTION_NONE: 2327 return 0; 2328 case Connection.TRANSACTION_READ_COMMITTED: 2329 return transactionCommittedMode; 2330 case Connection.TRANSACTION_READ_UNCOMMITTED: 2331 return transactionUncommittedMode; 2332 case Connection.TRANSACTION_REPEATABLE_READ: 2333 return transactionRepeatableMode; 2334 case Connection.TRANSACTION_SERIALIZABLE: 2335 return transactionSerializableMode; 2336 } 2337 } catch (SQLException se) { 2338 throw new DBException("Unable to retrieve transaction mode set " + 2339 " for this connection", se); 2340 } 2341 return -1; 2342 } 2343 2344 2345 2352 public boolean isAvailable() { 2353 return currentAvailable; 2354 } 2355 2356 2363 public boolean isClosed() 2364 throws DBException { 2365 2366 try { 2367 return myConnection.isClosed(); 2368 } catch (SQLException se) { 2369 throw new DBException(THIS_CLASS + "isClosed()" + ":Cannot access connection to " + 2370 "database via (driver or JNDI) '" + dbDriver + 2371 "' and URL '" + dbURL + "' (" + 2372 myDescription + ")", se.getMessage()); 2373 } 2374 } 2375 2376 2377 2384 public synchronized boolean next() 2385 throws DBException { 2386 touch(); 2387 checkTimeOut(); 2388 try { 2389 if (myResultSet == null) { 2390 throw new DBException(THIS_CLASS + "next()" + 2391 ":No result set established - " + 2392 "cannot select next record for statement '" + 2393 strSQL + "'"); 2394 } 2395 if (!myResultSet.next()) { 2396 2397 return false; 2398 } 2399 return true; 2400 } catch (SQLException se) { 2401 throw new DBException(THIS_CLASS + "next()" + ":Error retrieving next row for " + 2402 "statement " + strSQL + " (" + 2403 myDescription + ")", se.getMessage()); 2404 } 2405 } 2406 2407 2408 2415 public synchronized void rollback() 2416 throws DBException { 2417 if (this.supportsTransactions()) { 2418 try { 2419 myConnection.rollback(); 2420 } catch (SQLException se) { 2421 throw new DBException(THIS_CLASS + "rollback()" + ":Could not rollback" + " (" + 2422 myDescription + ")", se.getMessage()); 2423 } 2424 } 2425 2426 touch(); 2427 } 2428 2429 2430 2438 public synchronized void setAutoCommit(boolean b) 2439 throws DBException { 2440 if (this.supportsTransactions()) { 2441 try { 2442 myConnection.setAutoCommit(b); 2443 } catch (SQLException se) { 2444 throw new DBException(THIS_CLASS + "setAutoCommit(boolean)" + 2445 ":Could not set auto commit" + 2446 " (" + myDescription + ")", se.getMessage()); 2447 } 2448 } 2449 touch(); 2450 } 2451 2452 2453 2460 public synchronized void setAvailable(boolean newAvailable) { 2461 currentAvailable = newAvailable; 2462 touch(); 2463 } 2464 2465 2475 public synchronized void setDateTimeType(String newDateTimeType) 2476 throws DBException { 2477 if (newDateTimeType == null) { 2478 newDateTimeType = (""); 2479 } 2480 if (!newDateTimeType.equals("")) { 2481 dateTimeType = newDateTimeType; 2482 } else { 2483 throw new DBException(THIS_CLASS + "setDateTimeType(String)" + 2484 ":date/time type for database " + 2485 " must not be blank"); 2486 } 2487 } 2488 2489 2490 2498 public synchronized void setDescription(String newDescription) { 2499 if (newDescription != null) { 2500 myDescription = newDescription; 2501 } 2502 2503 touch(); 2504 } 2505 2506 2512 synchronized void setId(int newId) { 2513 connectionId = newId; 2514 } 2515 2516 2522 public synchronized void setImmortal(boolean newImmortal) { 2523 immortal = newImmortal; 2524 } 2525 2526 2531 public synchronized void setSQL(String sqlStatement) { 2532 strSQL = sqlStatement; 2533 } 2534 2535 2540 public synchronized void setEscapeHandler(EscapeHandler newValue) { 2541 this.escapeHandler = newValue; 2542 } 2543 2544 2545 2548 public synchronized void touch() { 2549 lastTouched = System.currentTimeMillis(); 2550 } 2551 2552 2553 2558 public synchronized void setDBName(String newDBName) { 2559 this.setDataContext(newDBName); 2560 } 2561 2562 2567 public synchronized void setDataContext(String newDBName) { 2568 if (StringUtil.notNull(newDBName).length() == 0) { 2569 dbName = DEFAULT_DB_CONTEXT_NAME; 2570 } else { 2571 dbName = newDBName; 2572 } 2573 } 2574 2575 2580 public String getDataContext() { 2581 return dbName; 2582 } 2583 2584 2589 public DBConnectionPool getParentPool() { 2590 return parentPool; 2591 } 2592 2593 2598 public void setParentPool(DBConnectionPool newParentPool) { 2599 this.parentPool = newParentPool; 2600 } 2601 2602 2613 public synchronized void release() { 2614 DBConnectionPool parent = getParentPool(); 2615 if (parent != null) { 2616 parent.release(this); 2617 } else { 2618 log.warn("No parent connection pool defined for this DBConnection"); 2619 } 2620 2621 } 2622 2623 public JNDIConfig getJNDIConfig(JDBCConfig curConfig) { 2624 if (curConfig instanceof com.jcorporate.expresso.core.misc.ConfigJdbc) { 2625 return ((com.jcorporate.expresso.core.misc.ConfigJdbc) curConfig).getMyJndi(); 2626 } else { 2627 return null; 2628 } 2629 } 2630 2631 2636 public String getDBName() { 2637 return this.getDataContext(); 2638 } 2639 2640 2641 2648 public void setTransactionIsolation(int isolationMode) 2649 throws DBException { 2650 try { 2651 if (supportsTransactions()) { 2652 myConnection.setTransactionIsolation(isolationMode); 2653 } 2654 } catch (SQLException se) { 2655 throw new DBException("Unable to set Database transaction isolation mode set " + 2656 " for this connection", se); 2657 } 2658 } 2659 2660 2667 public void setTransactionMode(int transactionMode) throws DBException { 2668 2669 try { 2670 switch (transactionMode) { 2671 case TRANSACTION_NORMAL_MODE: 2672 setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED); 2673 break; 2674 case TRANSACTION_DIRTY_MODE: 2675 setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED); 2676 break; 2677 case TRANSACTION_RESTRICTIVE_MODE: 2678 setTransactionIsolation(Connection.TRANSACTION_REPEATABLE_READ); 2679 break; 2680 case TRANSACTION_EXCLUSIVE_MODE: 2681 setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE); 2682 break; 2683 default: 2684 throw new IllegalArgumentException ("Unknown transaction mode: " + transactionMode); 2685 } 2686 } catch (DBException se) { 2687 throw new DBException("", se); 2688 } 2689 } 2690 2691 2698 public void setTransactionCommittedMode() throws DBException { 2699 2700 try { 2701 setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED); 2702 } catch (DBException se) { 2703 throw new DBException("", se); 2704 } 2705 } 2706 2707 2714 public void setTransactionUncommittedMode() throws DBException { 2715 2716 try { 2717 setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED); 2718 } catch (DBException se) { 2719 throw new DBException("", se); 2720 } 2721 } 2722 2723 2730 public void setTransactionRepeatableMode() throws DBException { 2731 2732 try { 2733 setTransactionIsolation(Connection.TRANSACTION_REPEATABLE_READ); 2734 } catch (DBException se) { 2735 throw new DBException("", se); 2736 } 2737 } 2738 2739 2746 public void setTransactionSerializableMode() throws DBException { 2747 2748 try { 2749 setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE); 2750 } catch (DBException se) { 2751 throw new DBException("", se); 2752 } 2753 } 2754 2755 2761 public boolean isStringNotTrim() { 2762 return myJdbc.isStringNotTrim(); 2763 } 2764 2765 2771 public boolean isTransactionNotActive() { 2772 return myJdbc.isTransactionNotActive(); 2773 } 2774 2775 2776 2779 public void setJDBCCondig(JDBCConfig config) { 2780 myJdbc = config; 2781 } 2782 2783} 2784 2785 2786 | Popular Tags |