当前位置:学学看123知识中心电脑教学数据库教程关于ORACLE连接池» 正文

关于ORACLE连接池

[06-11 18:18:52]   来源:http://www.xxk123.com  数据库教程   阅读:8664

导读: 128 int max; 129 try { 130 max = Integer.valueOf(maxconn).intValue(); 131 } 132 catch (NumberFormatException e) { 133 log("错误的最大连接数限制: " + maxconn + " .连接池: " + poolName); 134 max = 0; 135 } 136 DBConnectionPool pool = 137 new DBConnectionPool(poolName, url, user, password, max); 138 pools.put

关于ORACLE连接池,标签:sql数据库教程,access数据库教程,http://www.xxk123.com
128 int max;
129 try {
130 max = Integer.valueOf(maxconn).intValue();
131 }
132 catch (NumberFormatException e) {
133 log("错误的最大连接数限制: " + maxconn + " .连接池: " + poolName);
134 max = 0;
135 }
136 DBConnectionPool pool =
137 new DBConnectionPool(poolName, url, user, password, max);
138 pools.put(poolName, pool);
139 log("成功创建连接池" + poolName);
140 }
141 }
142 }
143
144 /**
145 * 读取属性完成初始化
146 */
147 private void init() {
148 InputStream is = getClass().getResourceAsStream("/db.properties");
149 Properties dbProps = new Properties();
150 try {
151 dbProps.load(is);
152 }
153 catch (Exception e) {
154 System.err.println("不能读取属性文件. " +
155 "请确保db.properties在CLASSPATH指定的路径中");
156 return;
157 }
158 String logFile = dbProps.getProperty("logfile", "DBConnectionManager.log");
159 try {
160 log = new PrintWriter(new FileWriter(logFile, true), true);
161 }
162 catch (IOException e) {
163 System.err.println("无法打开日志文件: " + logFile);
164 log = new PrintWriter(System.err);
165 }
166 loadDrivers(dbProps);
167 createPools(dbProps);
168 }
169
170 /**
171 * 装载和注册所有JDBC驱动程序\\r

172 *
173 * @param props 属性
174 */
175 private void loadDrivers(Properties props) {
176 String driverClasses = props.getProperty("drivers");
177 StringTokenizer st = new StringTokenizer(driverClasses);
178 while (st.hasMoreElements()) {
179 String driverClassName = st.nextToken().trim();
180 try {
181 Driver driver = (Driver)
182 Class.forName(driverClassName).newInstance();
183 DriverManager.registerDr

iver(driver);
184 drivers.addElement(driver);
185 log("成功注册JDBC驱动程序\\\" + driverClassName);
186 }
187 catch (Exception e) {
188 log("无法注册JDBC驱动程序: " +
189 driverClassName + ", 错误: " + e);
190 }
191 }
192 }
193
194 /**
195 * 将文本信息写入日志文件
196 */
197 private void log(String msg) {
198 log.println(new Date() + ": " + msg);

上一页  [1] [2] [3] [4] [5] [6] [7] [8]  下一页


Tag:数据库教程sql数据库教程,access数据库教程电脑教学 - 数据库教程
《关于ORACLE连接池》相关文章

Copyright 学学看123 All Right Reserved.

1 2 3 4 5 6 7 8 9 10