導航:首頁 > 網路數據 > 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擴大資料庫連接池相關的資料

熱點內容
如何從ftp下載文件夾 瀏覽:963
一隻狗和兩個男孩的電影 瀏覽:266
兩台windows怎麼傳文件 瀏覽:937
哪裡能看周星馳電影粵語版 瀏覽:66
無線感測器網路技術的實現方法 瀏覽:447
如何把文件中同類型文件選出來 瀏覽:307
信德財務軟體備份文件 瀏覽:884
如何無線手機注冊app 瀏覽:425
哪個付費小說app最好 瀏覽:58
文件名使用通配符的作用 瀏覽:339
!4_ '6h[Bz9zd.F 瀏覽:553
李釆潭 作品 瀏覽:9
有一部電影男主有雀斑 瀏覽:473
數據字典保存哪些信息 瀏覽:63
文件夾的圖片怎麼復制到word 瀏覽:110
壓縮文件照片如何導到桌面 瀏覽:605
ios中如何讀取doc文件 瀏覽:786
能在線播放的電影你懂的 瀏覽:11
汽車總動員英語在線觀看 瀏覽:99

友情鏈接