导航:首页 > 网络数据 > oracle扩大数据库连接池

oracle扩大数据库连接池

发布时间:2021-12-03 03:26:00

㈠ 如何更改Oracle数据库DBlink连接数

直接登陆plsqldev.exe,然后选dblink,就可以看到所有的dblink了,右键可以修改和删除。

sql创建过程:

*************SQL COMMAND中*****************
create public database link get_db_link connect to aaa identified by aaa using 'get_link';

***********tnsnames.ora 中:***********
get_link=
(description=
(address=(protocol=tcp)
(host=192.168.131.75)
(port=1521))
(connect_data=
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)

㈡ oracle 数据库连接数被占满怎么处理

oracle 数据库连接数被占满怎么处理
只能设置很大,不能无限
当前的连接数
select count(*) from v$process;
设置的最大连接数(默认值为150)
select value from v$parameter where name = 'processes';

㈢ ORACLE数据库能设置连接池有长连接,短连接的概念吗

ORACLE数据库能设置连接池来?
相对而言吧,短自连接一般连接然后执行sql然后关闭了,长连接连接执行保持连接执行一直延续,现在更多应用层都是连接池机制,会缓存连接资源到连接池中不断重用,这个连接相对而言是长连接,主要是减小频繁的连接数据库带来的资源消耗。

㈣ 如何增加oracle连接最大进程数

在数据库服务器上运行 sqlplus system/password@xe (其中 system 是数据库用户无需改变;
password 是数据库密码应指定为实际密码;xe 是数据库实例名称) ,然后执行:
查看一下数据库现有的进程数,是否已经达到参数processes的大小。
1.select count(*) from v$process;取得数据库目前的进程数。
2.select value from v$parameter where name = 'processes';取得进程数的上限。

alter system set session_cached_cursors=200 scope=spfile;
alter system set session_max_open_files=200 scope=spfile;
alter system set sessions=20 scope=spfile;
alter system set license_max_sessions=200 scope=spfile;
alter system set license_sessions_warning=200 scope=spfile;
alter system set processes=200 scope=spfile;

执行后,重启 Oracle XE 数据库实例即可。要重启 Oracle XE 数据库实例:

1. 如安装于 Windows 上,先运行 net stop oracleservicexe,再运行 net start oracleservicexe 即可。也可通过“服务”管理控制台重启 OracleServiceXE 服务。
2. 如安装于 Linux 上,先运行 /etc/init.d/oracle-xe start,再运行 /etc/init.d/oracle-xe stop 即可。

㈤ oracle数据库连接池怎么配置

连接池是创建和管理多个连接的一种技术,这些连接可被需要使用它们的任何线程使用。连接池技术基于下述事实:对于大多数应用程序,当它们正在处理通常需要数毫秒完成的事务时,仅需要能够访问JDBC连接的1个线程。未处理事务时,连接处于闲置状态。使用连接池,允许其他线程使用闲置连接来执行有用的任务。事实上,当某一线程需要用JDBC在MySQL或其他数据库上执行操作时,需要用到由连接池提供的连接。使用连接完成线程后,线程会将连接返回给连接池,以便该连接能够被其他需要使用连接的线程使用。从连接池“借出”连接时,该连接仅供请求它的线程使用。从编程观点看,其效果等同于每次需要JDBC连接时调用DriverManager.getConnection(),但是,采用连接池技术,可通过使用新的或已有的连接结束线程。连接池技术能显著增加java应用程序的性能,同时还能降低资源使用率。
http://blog.csdn.net/xilangyuyun/article/details/52800380

㈥ 如何修改oracle数据库连接数

select count(*) from v$process --当前的连接数 select value from v$parameter where name = 'processes' --数据库允许的最大连接数 修改最大连接数: alter system set processes = 300 scope = spfile; 重启数据库: shutdown immediate; startup;

㈦ oracle数据库连接池怎么看

写JDBC connection pool 的注意事项有:
1. 有一个简单的函数从连接池中得到一个 Connection。
2. close 函数必须将connection 放回 数据库连接池。
3. 当数据库连接池中没有空闲的connection,数据库连接池必须能够自动增加connection 个数。
4. 当数据库连接池中的connection 个数在某一个特别的时间变得很大,但是以后很长时间只用其中一小部分,应该可以自动将多余的connection 关闭掉。
5. 如果可能,应该提供debug 信息报告没有关闭的new Connection 。
如果要new Connection 就可以直接从数据库连接池中返回Connection, 可以这样写( Mediator pattern ) (以下代码中使用了中文全角空格):
public class EasyConnection implements java.sql.Connection{
private Connection m_delegate = null;
public EasyConnection(){
m_delegate = getConnectionFromPool();
}
public void close(){
putConnectionBackToPool(m_delegate);
}
public PreparedStatement prepareStatement(String sql) throws SQLException{
m_delegate.prepareStatement(sql);
}
//...... other method
}
看来并不难。不过不建议这种写法,因为应该尽量避免使用Java Interface, 关于Java Interface 的缺点我另外再写文章讨论。大家关注的是Connection Pool 的实现方法。下面给出一种实现方法。
import java.sql.*;
import java.lang.reflect.*;
import java.util.*;
import java.io.*;

public class SimpleConnetionPool {
private static LinkedList m_notUsedConnection = new LinkedList();
private static HashSet m_usedUsedConnection = new HashSet();
private static String m_url = "";
private static String m_user = "";
private static String m_password = "";
static final boolean DEBUG = true;
static private long m_lastClearClosedConnection = System.currentTimeMillis();
public static long CHECK_CLOSED_CONNECTION_TIME = 4 * 60 * 60 * 1000; //4 hours

static {
initDriver();
}

private SimpleConnetionPool() {
}

private static void initDriver() {
Driver driver = null;
//load mysql driver
try {
driver = (Driver) Class.forName("com.mysql.jdbc.Driver").newInstance();
installDriver(driver);
} catch (Exception e) {
}

//load postgresql driver
try {
driver = (Driver) Class.forName("org.postgresql.Driver").newInstance();
installDriver(driver);
} catch (Exception e) {
}
}

public static void installDriver(Driver driver) {
try {
DriverManager.registerDriver(driver);
} catch (Exception e) {
e.printStackTrace();
}
}

public static synchronized Connection getConnection() {
clearClosedConnection();
while (m_notUsedConnection.size() > 0) {
try {
ConnectionWrapper wrapper = (ConnectionWrapper) m_notUsedConnection.removeFirst();
if (wrapper.connection.isClosed()) {
continue;
}
m_usedUsedConnection.add(wrapper);
if (DEBUG) {
wrapper.debugInfo = new Throwable("Connection initial statement");
}
return wrapper.connection;
} catch (Exception e) {
}
}
int newCount = getIncreasingConnectionCount();
LinkedList list = new LinkedList();
ConnectionWrapper wrapper = null;
for (int i = 0; i < newCount; i++) {
wrapper = getNewConnection();
if (wrapper != null) {
list.add(wrapper);
}
}
if (list.size() == 0) {
return null;
}
wrapper = (ConnectionWrapper) list.removeFirst();
m_usedUsedConnection.add(wrapper);

m_notUsedConnection.addAll(list);
list.clear();

return wrapper.connection;
}

private static ConnectionWrapper getNewConnection() {
try {
Connection con = DriverManager.getConnection(m_url, m_user, m_password);
ConnectionWrapper wrapper = new ConnectionWrapper(con);
return wrapper;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}

static synchronized void pushConnectionBackToPool(ConnectionWrapper con) {
boolean exist = m_usedUsedConnection.remove(con);
if (exist) {
m_notUsedConnection.addLast(con);
}
}

public static int close() {
int count = 0;

Iterator iterator = m_notUsedConnection.iterator();
while (iterator.hasNext()) {
try {
( (ConnectionWrapper) iterator.next()).close();
count++;
} catch (Exception e) {
}
}
m_notUsedConnection.clear();

iterator = m_usedUsedConnection.iterator();
while (iterator.hasNext()) {
try {
ConnectionWrapper wrapper = (ConnectionWrapper) iterator.next();
wrapper.close();
if (DEBUG) {
wrapper.debugInfo.printStackTrace();
}
count++;
} catch (Exception e) {
}
}
m_usedUsedConnection.clear();

return count;
}

private static void clearClosedConnection() {
long time = System.currentTimeMillis();
//sometimes user change system time,just return
if (time < m_lastClearClosedConnection) {
time = m_lastClearClosedConnection;
return;
}
//no need check very often
if (time - m_lastClearClosedConnection < CHECK_CLOSED_CONNECTION_TIME) {
return;
}
m_lastClearClosedConnection = time;

//begin check
Iterator iterator = m_notUsedConnection.iterator();
while (iterator.hasNext()) {
ConnectionWrapper wrapper = (ConnectionWrapper) iterator.next();
try {
if (wrapper.connection.isClosed()) {
iterator.remove();
}
} catch (Exception e) {
iterator.remove();
if (DEBUG) {
System.out.println("connection is closed, this connection initial StackTrace");
wrapper.debugInfo.printStackTrace();
}
}
}

//make connection pool size smaller if too big
int decrease = getDecreasingConnectionCount();
if (m_notUsedConnection.size() < decrease) {
return;
}

while (decrease-- > 0) {
ConnectionWrapper wrapper = (ConnectionWrapper) m_notUsedConnection.removeFirst();
try {
wrapper.connection.close();
} catch (Exception e) {
}
}
}

public static int getIncreasingConnectionCount() {
int count = 1;
int current = getConnectionCount();
count = current / 4;
if (count < 1) {
count = 1;
}
return count;
}

public static int getDecreasingConnectionCount() {
int count = 0;
int current = getConnectionCount();
if (current < 10) {
return 0;
}
return current / 3;
}

public synchronized static void printDebugMsg() {
printDebugMsg(System.out);
}

public synchronized static void printDebugMsg(PrintStream out) {
if (DEBUG == false) {
return;
}
StringBuffer msg = new StringBuffer();
msg.append("debug message in " + SimpleConnetionPool.class.getName());
msg.append("\r\n");
msg.append("total count is connection pool: " + getConnectionCount());
msg.append("\r\n");
msg.append("not used connection count: " + getNotUsedConnectionCount());
msg.append("\r\n");
msg.append("used connection, count: " + getUsedConnectionCount());
out.println(msg);
Iterator iterator = m_usedUsedConnection.iterator();
while (iterator.hasNext()) {
ConnectionWrapper wrapper = (ConnectionWrapper) iterator.next();
wrapper.debugInfo.printStackTrace(out);
}
out.println();
}

public static synchronized int getNotUsedConnectionCount() {
return m_notUsedConnection.size();
}

public static synchronized int getUsedConnectionCount() {
return m_usedUsedConnection.size();
}

public static synchronized int getConnectionCount() {
return m_notUsedConnection.size() + m_usedUsedConnection.size();
}

public static String getUrl() {
return m_url;
}

public static void setUrl(String url) {
if (url == null) {
return;
}
m_url = url.trim();
}

public static String getUser() {
return m_user;
}

public static void setUser(String user) {
if (user == null) {
return;
}
m_user = user.trim();
}

public static String getPassword() {
return m_password;
}

public static void setPassword(String password) {
if (password == null) {
return;
}
m_password = password.trim();
}

}

class ConnectionWrapper implements InvocationHandler {
private final static String CLOSE_METHOD_NAME = "close";
public Connection connection = null;
private Connection m_originConnection = null;
public long lastAccessTime = System.currentTimeMillis();
Throwable debugInfo = new Throwable("Connection initial statement");

ConnectionWrapper(Connection con) {
this.connection = (Connection) Proxy.newProxyInstance(
con.getClass().getClassLoader(),
new Class[]{Connection.class}, this);
m_originConnection = con;
}

void close() throws SQLException {
m_originConnection.close();
}

public Object invoke(Object proxy, Method m, Object[] args) throws Throwable {
Object obj = null;
if (CLOSE_METHOD_NAME.equals(m.getName())) {
SimpleConnetionPool.pushConnectionBackToPool(this);
}
else {
obj = m.invoke(m_originConnection, args);
}
lastAccessTime = System.currentTimeMillis();
return obj;
}
}

㈧ oracle 如何增大连接池最大连接数

单纯靠增大max pool size=512 的值来增大连接数 应该并不能解决你的问题。应该正常的来说 512的连回接数已经足够多的了,入答股还出现超过连接数的话,说明你的代码里有大量的数据库连接没有关闭,造成连接池泄漏,需要重新检查你的源代码,一个数据库连接使用完毕后要及时关闭,否则你设置再大的连接数也没有用,只是网站崩溃的时间晚一点而已。

㈨ 如何修改oracle数据库最大连接数

select count(*) from v$process --当前的连接数
select value from v$parameter where name = 'processes' --数据库允许的最大连专接数
修改最大连接数:
alter system set processes = 300 scope = spfile;
重启属数据库:
shutdown immediate;
startup;

阅读全文

与oracle扩大数据库连接池相关的资料

热点内容
出租菜园在什么网站 浏览:575
iphone5stxt 浏览:675
香港动作理论电影 浏览:776
凪江 日本 浏览:888
传感器怎么编程的用网线 浏览:782
pdf文件如何变为图片 浏览:151
[中文字幕] MDY 浏览:160
法国漏器官电影 浏览:740
老电影怀旧电影全剧 浏览:493
期货数据统计在哪里来 浏览:183
电影里的女人喂宝宝 浏览:141
韩国女社长劈腿电影 浏览:529
阿根廷十大艳情片 浏览:2
数据线长度怎么调整 浏览:132
2345好压支持win10吗 浏览:845
日本和韩国好看的推理片 浏览:157
卷屏app怎么用 浏览:35
手机qq群里昵称怎么改名字 浏览:27
韩国电影男的通过楼上洞偷窥女的跳舞 浏览:537
日韩欧美推理片电影 浏览:31

友情链接